cosmos-sdk/simapp
Ian Norden 1326fa2a7d
feat: ADR-038 Part 2: StreamingService interface, file writing implementation, and configuration (#8664)
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰
v    Before smashing the submit button please review the checkboxes.
v    If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review.
-->

Hello 👋 this PR introduces the second stage of changes to support [ADR-038](https://github.com/cosmos/cosmos-sdk/pull/8012) state listening. This is rebased on top of the [first segment](https://github.com/cosmos/cosmos-sdk/pull/8551), which introduces the low level changes to the MultiStore and KVStore interfaces and implementations, the new WriteListener types, and the new listen.KVStore type.

In this segment we introduce the StreamingService interface, an implementation that writes out to files, and it's integration and configuration at the BaseApp level.

The idea was to have the first segment reviewed independently first but if people think it is easier/more time efficient to review both at the same time then we could start here.

Thanks!



This work is towards satisfying [ADR-038](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-038-state-listening.md)

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [x] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [x] Re-reviewed `Files changed` in the Github PR explorer
- [x] Review `Codecov Report` in the comment section below once CI passes
2021-10-24 21:37:37 +00:00
..
helpers revert: Remove SIGN_MODE_AMINO_AUX (#10322) 2021-10-18 10:32:43 +00:00
params fix(CI): add golangci-lint to dependencies (#10112) 2021-09-14 11:05:30 +02:00
simd fix: --home flag parsing (#10226) 2021-09-30 12:01:56 +00:00
README.md chore: add markdownlint to lint commands (#9353) 2021-05-27 15:31:04 +00:00
app.go feat: ADR-038 Part 2: StreamingService interface, file writing implementation, and configuration (#8664) 2021-10-24 21:37:37 +00:00
app_test.go feat(tests): add simapp setup helpers (#10020) 2021-09-15 17:18:01 -04:00
config.go Remove dependency of types/module package on x/simulation (#5835) 2020-03-23 12:55:44 +01:00
encoding.go codecs: rename MakeCodecs rename and docs update (#8245) 2021-01-07 21:50:52 +00:00
export.go feat!: add error handling to staking hooks (#9571) 2021-06-30 10:13:07 +00:00
genesis.go x/authz: audit updates (#9042) 2021-05-06 18:23:48 +00:00
genesis_account.go x/auth: remove alias.go usage (#6440) 2020-06-17 14:42:27 -04:00
genesis_account_test.go Update tm pubkey references (#7102) 2020-08-28 16:02:38 +00:00
sim_bench_test.go simapp, types: fix benchmarks panics by honoring skip if set (#8763) 2021-03-03 03:54:14 -08:00
sim_test.go feat!: Ensure InitGenesis returns with non-empty validator set (#9697) 2021-10-05 12:02:51 +00:00
state.go refactor: move from io/ioutil to io and os package (#10341) 2021-10-13 07:38:22 +00:00
test_helpers.go feat!: Ensure InitGenesis returns with non-empty validator set (#9697) 2021-10-05 12:02:51 +00:00
types.go Add height in exported genesis (#7089) 2020-09-03 10:11:46 +00:00
utils.go refactor: move from io/ioutil to io and os package (#10341) 2021-10-13 07:38:22 +00:00
utils_test.go codec: Rename codec and marshaler interfaces (#9226) 2021-04-29 10:46:22 +00:00

README.md

order
false

simapp

simapp is an application built using the Cosmos SDK for testing and educational purposes.

Running testnets with simd

If you want to spin up a quick testnet with your friends, you can follow these steps. Unless otherwise noted, every step must be done by everyone who wants to participate in this testnet.

  1. From the root directory of the Cosmos SDK repository, run $ make build. This will build the simd binary inside a new build directory. The following instructions are run from inside the build directory.

  2. If you've run simd before, you may need to reset your database before starting a new testnet. You can reset your database with the following command: $ ./simd unsafe-reset-all.

  3. $ ./simd init [moniker] --chain-id [chain-id]. This will initialize a new working directory at the default location ~/.simapp. You need to provide a "moniker" and a "chain id". These two names can be anything, but you will need to use the same "chain id" in the following steps.

  4. $ ./simd keys add [key_name]. This will create a new key, with a name of your choosing. Save the output of this command somewhere; you'll need the address generated here later.

  5. $ ./simd add-genesis-account [key_name] [amount], where key_name is the same key name as before; and amount is something like 10000000000000000000000000stake.

  6. $ ./simd gentx [key_name] [amount] --chain-id [chain-id]. This will create the genesis transaction for your new chain. Here amount should be at least 1000000000stake. If you provide too much or too little, you will encounter an error when starting your node.

  7. Now, one person needs to create the genesis file genesis.json using the genesis transactions from every participant, by gathering all the genesis transactions under config/gentx and then calling $ ./simd collect-gentxs. This will create a new genesis.json file that includes data from all the validators (we sometimes call it the "super genesis file" to distinguish it from single-validator genesis files).

  8. Once you've received the super genesis file, overwrite your original genesis.json file with the new super genesis.json.

  9. Modify your config/config.toml (in the simapp working directory) to include the other participants as persistent peers:

    # Comma separated list of nodes to keep persistent connections to
    persistent_peers = "[validator_address]@[ip_address]:[port],[validator_address]@[ip_address]:[port]"
    

    You can find validator_address by running $ ./simd tendermint show-node-id. The output will be the hex-encoded validator_address. The default port is 26656.

  10. Now you can start your nodes: $ ./simd start.

Now you have a small testnet that you can use to try out changes to the Cosmos SDK or Tendermint!

NOTE: Sometimes creating the network through the collect-gentxs will fail, and validators will start in a funny state (and then panic). If this happens, you can try to create and start the network first with a single validator and then add additional validators using a create-validator transaction.