cosmos-sdk/server
dependabot[bot] ea8b0f731d
build(deps): Bump github.com/tendermint/tendermint from 0.35.2 to 0.35.3 (#11599)
Bumps [github.com/tendermint/tendermint](https://github.com/tendermint/tendermint) from 0.35.2 to 0.35.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tendermint/tendermint/releases">github.com/tendermint/tendermint's releases</a>.</em></p>
<blockquote>
<h2>0.35.3 (WARNING: BETA SOFTWARE)</h2>
<p><a href="https://github.com/tendermint/tendermint/blob/v0.35.3/CHANGELOG.md#v0.35.3">https://github.com/tendermint/tendermint/blob/v0.35.3/CHANGELOG.md#v0.35.3</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md">github.com/tendermint/tendermint's changelog</a>.</em></p>
<blockquote>
<h2>v0.35.3</h2>
<p>April 8, 2022</p>
<h3>FEATURES</h3>
<ul>
<li>[cli] <a href="https://github-redirect.dependabot.com/tendermint/tendermint/pull/8081">#8081</a> add a safer-to-use <code>reset-state</code> command. (<a href="https://github.com/marbar3778"><code>@​marbar3778</code></a>)</li>
</ul>
<h3>IMPROVEMENTS</h3>
<ul>
<li>[consensus] <a href="https://github-redirect.dependabot.com/tendermint/tendermint/pull/8138">#8138</a> change lock handling in reactor and handleMsg for RoundState. (<a href="https://github.com/williambanfield"><code>@​williambanfield</code></a>)</li>
</ul>
<h3>BUG FIXES</h3>
<ul>
<li>[cli] <a href="https://github-redirect.dependabot.com/tendermint/tendermint/pull/8276">#8276</a> scmigrate: ensure target key is correctly renamed. (<a href="https://github.com/creachadair"><code>@​creachadair</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="dfa001f5c7"><code>dfa001f</code></a> Prepare changelog for release v0.35.3. (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8289">#8289</a>)</li>
<li><a href="5f7031432d"><code>5f70314</code></a> build(deps): Bump github.com/lib/pq from 1.10.4 to 1.10.5 (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8282">#8282</a>)</li>
<li><a href="fb7ce48c15"><code>fb7ce48</code></a> scmigrate: ensure target key is correctly renamed (backport <a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8276">#8276</a>) (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8280">#8280</a>)</li>
<li><a href="308d283241"><code>308d283</code></a> cli: fix reset command for v0.35 (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8259">#8259</a>)</li>
<li><a href="530e81dea4"><code>530e81d</code></a> Fix broken links in the changelog. (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8268">#8268</a>)</li>
<li><a href="5051a1ce82"><code>5051a1c</code></a> build(deps): Bump github.com/BurntSushi/toml from 1.0.0 to 1.1.0 (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8253">#8253</a>)</li>
<li><a href="ac881db09a"><code>ac881db</code></a> build(deps): Bump github.com/vektra/mockery/v2 from 2.10.2 to 2.10.4 (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8254">#8254</a>)</li>
<li><a href="14461339f4"><code>1446133</code></a> Update golangci-lint-action and golang-ci versions. (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8256">#8256</a>)</li>
<li><a href="21da336656"><code>21da336</code></a> build(deps): Bump github.com/vektra/mockery/v2 from 2.10.1 to 2.10.2 (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8247">#8247</a>)</li>
<li><a href="524d3ceb88"><code>524d3ce</code></a> e2e: Fix hashing for app + Fix logic of TestApp_Hash (backport <a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8229">#8229</a>) (<a href="https://github-redirect.dependabot.com/tendermint/tendermint/issues/8236">#8236</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tendermint/tendermint/compare/v0.35.2...v0.35.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/tendermint/tendermint&package-manager=go_modules&previous-version=0.35.2&new-version=0.35.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
2022-04-12 05:19:38 +00:00
..
api chore: bump TM to v0.35.0 release candidate (#10210) 2021-11-16 11:24:38 -08:00
cmd fix(server/cmd)!: set environment prefix (#10950) 2022-01-20 14:04:21 +00:00
config feat: api server flags to start command (#11511) 2022-04-01 07:40:48 +00:00
grpc fix: dockerfile for building proto (#11452) 2022-03-25 12:35:09 +00:00
mock feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry (#11188) 2022-03-18 10:26:20 +01:00
rosetta refactor: Change SignerData.SignerIndex to PubKey (#10692) 2021-12-08 11:43:15 +00:00
types chore: bump TM to v0.35.0 release candidate (#10210) 2021-11-16 11:24:38 -08:00
README.md docs: Improve markdownlint configuration (#11104) 2022-02-10 12:07:01 +00:00
constructors_test.go feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry (#11188) 2022-03-18 10:26:20 +01:00
doc.go
export.go feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry (#11188) 2022-03-18 10:26:20 +01:00
export_test.go chore: bump TM to v0.35.0 release candidate (#10210) 2021-11-16 11:24:38 -08:00
logger.go
pruning.go refactor!: remove 'keep-every' from pruning (#11152) 2022-02-12 10:54:04 -05:00
pruning_test.go refactor!: remove 'keep-every' from pruning (#11152) 2022-02-12 10:54:04 -05:00
rollback.go feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry (#11188) 2022-03-18 10:26:20 +01:00
rosetta.go
start.go feat: api server flags to start command (#11511) 2022-04-01 07:40:48 +00:00
test_helpers.go
tm_cmds.go build(deps): Bump github.com/tendermint/tendermint from 0.35.2 to 0.35.3 (#11599) 2022-04-12 05:19:38 +00:00
util.go build(deps): Bump github.com/tendermint/tendermint from 0.35.2 to 0.35.3 (#11599) 2022-04-12 05:19:38 +00:00
util_test.go feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry (#11188) 2022-03-18 10:26:20 +01:00

README.md

Server

The server package is responsible for providing the mechanisms necessary to start an ABCI Tendermint application and provides the CLI framework (based on cobra) necessary to fully bootstrap an application. The package exposes two core functions: StartCmd and ExportCmd which creates commands to start the application and export state respectively.

Preliminary

The root command of an application typically is constructed with:

  • command to start an application binary
  • three meta commands: query, tx, and a few auxiliary commands such as genesis. utilities.

It is vital that the root command of an application uses PersistentPreRun() cobra command property for executing the command, so all child commands have access to the server and client contexts. These contexts are set as their default values initially and maybe modified, scoped to the command, in their respective PersistentPreRun() functions. Note that the client.Context is typically pre-populated with "default" values that may be useful for all commands to inherit and override if necessary.

Example:

var (
	initClientCtx  = client.Context{...}

	rootCmd = &cobra.Command{
		Use:   "simd",
		Short: "simulation app",
		PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
			if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
				return err
			}

			return server.InterceptConfigsPreRunHandler(cmd)
		},
	}
    // add root sub-commands ...
)

The SetCmdClientContextHandler call reads persistent flags via ReadPersistentCommandFlags which creates a client.Context and sets that on the root command's Context.

The InterceptConfigsPreRunHandler call creates a viper literal, default server.Context, and a logger and sets that on the root command's Context. The server.Context will be modified and saved to disk via the internal interceptConfigs call, which either reads or creates a Tendermint configuration based on the home path provided. In addition, interceptConfigs also reads and loads the application configuration, app.toml, and binds that to the server.Context viper literal. This is vital so the application can get access to not only the CLI flags, but also to the application configuration values provided by this file.

StartCmd

The StartCmd accepts an AppCreator function which returns an Application. The AppCreator is responsible for constructing the application based on the options provided to it via AppOptions. The AppOptions interface type defines a single method, Get() interface{}, and is implemented as a viper literal that exists in the server.Context. All the possible options an application may use and provide to the construction process are defined by the StartCmd and by the application's config file, app.toml.

The application can either be started in-process or as an external process. The former creates a Tendermint service and the latter creates a Tendermint Node.

Under the hood, StartCmd will call GetServerContextFromCmd, which provides the command access to a server.Context. This context provides access to the viper literal, the Tendermint config and logger. This allows flags to be bound the viper literal and passed to the application construction.

Example:

func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts server.AppOptions) server.Application {
	var cache sdk.MultiStorePersistentCache

	if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
		cache = store.NewCommitKVStoreCacheManager()
	}

	skipUpgradeHeights := make(map[int64]bool)
	for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
		skipUpgradeHeights[int64(h)] = true
	}

	pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
	if err != nil {
		panic(err)
	}

	return simapp.NewSimApp(
		logger, db, traceStore, true, skipUpgradeHeights,
		cast.ToString(appOpts.Get(flags.FlagHome)),
		cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
		baseapp.SetPruning(pruningOpts),
		baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
		baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
		baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
		baseapp.SetInterBlockCache(cache),
		baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
	)
}

Note, some of the options provided are exposed via CLI flags in the start command and some are also allowed to be set in the application's app.toml. It is recommend to use the cast package for type safety guarantees and due to the limitations of CLI flag types.