Commit Graph

554 Commits

Author SHA1 Message Date
Mark Rushakoff
1bb632a567
chore: prefer to panic instead of os.Exit (#15285) 2023-03-07 15:12:39 +00:00
Mark Rushakoff
e7097b1468
test: add cmdtest package (#15251)
## Description

This PR introduces the `cmdtest` package, offering a lightweight wrapper around cobra commands to simplify testing CLI utilities.

I backfilled tests for the `version` command, which was an example of a very simple test setup; and for the `export` command, which was more involved due to the server and client context requirements.

I did notice that there are some existing tests for some utilities, but the `cmdtest` package follows a simple pattern that has been easy to use successfully in [the relayer](https://github.com/cosmos/relayer/blob/main/internal/relayertest/system.go) and in other projects outside the Cosmos ecosystem.

While filling in these tests, I started removing uses of `cmd.Print`, as that is the root cause of issues like #8498, #7964, #15167, and possibly others. Internal to cobra, the print family of methods write to `cmd.OutOrStderr()` -- meaning that if the authors call `cmd.SetOutput()` before executing the command, the output will be written to stdout as expected; otherwise it will go to stderr. I don't understand why that would be the default behavior, but it is probably too late to change from cobra's side.

Instead of `cmd.Print`, we prefer to `fmt.Fprint(cmd.OutOrStdout())` or `fmt.Fprint(cmd.ErrOrStderr())` as appropriate, giving an unambiguous destination for output. And the new tests collect those outputs in plain `bytes.Buffer` values so that we can assert their content appropriately.

In the longer term, I would like to deprecate and eventually remove the `testutil` package's `ApplyMockIO` method and its `BufferWriter` and `BufferReader` types, as they are unnecessary indirection when a simpler solution exists. But that can wait until `cmdtest` has propagated through the codebase more.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] ~~provided a link to the relevant issue or specification~~
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] confirmed that this PR does not change production code
2023-03-06 19:40:24 +00:00
Mark Rushakoff
f151bf627a
refactor(log): require destination in calls to NewLogger (#15262) 2023-03-06 19:05:49 +00:00
Mark Rushakoff
fab029bff5
refactor(log): associate test logger with testing.T instance (#15261) 2023-03-03 20:26:45 +00:00
Mark Rushakoff
9150a9d255
test(server/grpc): avoid using deprecated protoreflect function (#15221)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-03-01 16:55:48 +00:00
Mark Rushakoff
261af6721b
test: use pointer receivers to avoid lock copies (#15217)
## Description
There were several test suite methods that had a value receiver, and which were being ignored for linting. Instead of ignoring the error, use pointer receivers to properly avoid lock copying.

And use a local copy of one loop variable in a possible closure.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] ~~provided a link to the relevant issue or specification~~
- [ ] ~~reviewed "Files changed" and left comments if necessary~~
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] confirmed that this PR does not change production code
2023-02-28 18:27:57 +00:00
Julien Robert
d2977478bc
feat: use go embed for swagger (#15216) 2023-02-28 15:21:38 +00:00
Julien Robert
5d559dd265
feat!: use cosmossdk.io/log logger (#15011) 2023-02-27 21:36:22 +00:00
Aleksandr Bezobchuk
41690532be
refactor: Refactor TxSearch (#14758)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-02-24 16:08:53 +00:00
Aleksandr Bezobchuk
7f99ad5fe7
refactor: cleanup server logic (#15041) 2023-02-22 16:09:08 +00:00
Julien Robert
832517befc
feat: add application genesis (#15031) 2023-02-22 10:29:03 +00:00
Facundo Medica
4a6a1e3cb8
refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
yihuang
497dc2cb78
fix: create snapshot dir for rocksdb backend (#15054) 2023-02-17 17:05:40 +00:00
cipherZ
86eca4c72b
feat: Integrate tendermint Block endpoints into the cli (#14659)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-02-14 19:23:45 +01:00
yihuang
4d02519ec0
feat: support profiling block replay during abci handshake (#14953)
## Description

by default, the signal trap is not setup during abci handshake, so you can't profile at this stage, but it's an interesting way to profile production block data with the block replay. 



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2023-02-08 23:53:27 +00:00
Julien Robert
c17c3caab8
refactor: rename commands to match consensus engine name (#14956) 2023-02-08 20:09:28 +00:00
Julien Robert
a7ac29e3f4
chore: rename log pkg and add zerolog (#14955) 2023-02-08 11:32:22 +00:00
Marko
281017ae90
refactor: use cosmos-sdk/log throughout (#14909)
## Description

removes the dependency of tendermint/utils/log from countless locations. This is in effort of reducing Tendermint's lib usage in the sdk 

this is nonbreaking as the interface is the same. To eliminate tm/utils/log in the sdk we need a few more things. Once we have fully removed the tendermint logger, I would propose we break the interface and define our own for our use case, when we pass the logger to tendermint in the node.New() function we can wrap our logger for its use case 

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2023-02-07 10:54:48 +00:00
Jeon Jeongho
a186d2a69f
docs: correct rpc-max-body-bytes config description (#14935)
## Description

This config limits the maximum size of HTTP request body, but description said response size. `rpc-max-body-bytes` config affects these:
* 38a4caeac0/rpc/jsonrpc/server/http_server.go (L255)
* 1cb55d49ba/rpc/jsonrpc/server/ws_handler.go (L167)

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2023-02-07 09:19:32 +00:00
Julien Robert
80dd55f79b
refactor: rename to CometBFT (#14914) 2023-02-06 18:11:14 +00:00
Julien Robert
41a3dfeced
refactor!: migrate Cosmos SDK to CometBFT (#14897) 2023-02-05 14:51:33 +01:00
Sylvain Bellemare
c9ba06bf77
docs: fix typo (#14905)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
2023-02-03 23:59:53 +00:00
Julien Robert
12394c8b99
fix: allow grpc server enabled even when api off (#14890) 2023-02-02 20:34:46 +01:00
yihuang
b266522c88
feat: add config iavl-lazy-loading to enable lazy loading of iavl store (#14189)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-31 21:52:32 +00:00
Facundo Medica
deeb4bd362
feat!: return errors in module manager ABCI methods (#14847) 2023-01-31 19:17:04 +00:00
Amaury
d0a5bd1a05
fix(reflection): Fix gogoproto import paths (#14838) 2023-01-31 11:12:52 +00:00
Likhita Polavarapu
7559d9ecd3
refactor: create go.mod for store (#14746)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-25 13:31:56 +00:00
Julien Robert
4f6f6c0002
feat: use same port for grpc-web and api server (#14652) 2023-01-20 15:07:17 +00:00
Noel Ukwa
c822836501
refactor: migrate calls from alias file to appropriate store/types (#14455)
Co-authored-by: Marko <marbar3778@yahoo.com>
Closes https://github.com/cosmos/cosmos-sdk/issues/14406
2023-01-10 15:31:06 +00:00
Marc-Antoine Dumais
465e0f6199
docs: remove default iavl-cache-size invalid value (#14486) 2023-01-05 21:24:00 +00:00
Marko
e048402efb
chore: modify db support (#14451) 2022-12-30 14:08:37 +00:00
Marko
f3dd51029a
refactor: remove global metrics in store (#14439) 2022-12-30 14:46:29 +01:00
Julien Robert
82bd8880fc
fix: fix --log_format flag not working (#14441) 2022-12-29 10:09:16 +01:00
Jacob Gadikian
1bb0629846
chore: iavl-v0.20-alpha1 and cosmos-db (#14411)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2022-12-28 21:42:00 +01:00
Marko
7d2ba36357
refactor: pass logger to store (#14438) 2022-12-28 13:20:44 +01:00
Marko
3684966676
chore: remove unused code from server (#14437) 2022-12-27 23:46:12 +00:00
Facundo Medica
edb5c1c0d7
chore: audit server (#14367) 2022-12-20 14:56:13 +00:00
Aleksandr Bezobchuk
bbd7e31305
chore: audit server package (#14359) 2022-12-19 19:42:09 +00:00
Jacob Gadikian
be8c5a09c2
chore: lint tests (#14268) 2022-12-18 23:48:31 +00:00
Aleksandr Bezobchuk
ae2c762bd3
chore: audit store/streaming/file/service.go (#14234) 2022-12-10 17:15:29 +01:00
Aleksandr Bezobchuk
66dd2be12c
chore: cleanup baseapp tests (#14162) 2022-12-06 16:52:36 +00:00
Marko
1b6192fec0
refactor: provide a helper for baseapp options (#14175)
* provide a helper for baseapp options

* rename

* changelog entry

* fix spelling
2022-12-06 14:28:18 +00:00
Marko
ca0b1deeea
chore: bound mempool size by default (#14135) 2022-12-02 15:57:22 +00:00
yihuang
1f91ee2ee9
fix: state listener observe writes at wrong time (#13516)
* fix: state listener observe writes at wrong time

Closes: #13457

Currently state listener is notified when the cache store write, which happens in commit event only, which breaks the current design.
The solution (as discussed in the issue) is to listen state writes on rootmulti store only.

It also changes the file streamer to output single data file for the writes in the whole block, since we can't distinguish writes from different stage of abci events.

It adds new config items for file streamer:
- streamers.file.output-metadata
- streamers.file.stop-node-on-error
- streamers.file.fsync

* synchronous abci call, and format doc

* fix comment

* update file streamer readme and fix typos

* typo

* fix: state listener observe writes at wrong time

Closes: #13457

Currently state listener is notified when the cache store write, which happens in commit event only, which breaks the current design.
The solution (as discussed in the issue) is to listen state writes on rootmulti store only.

It also changes the file streamer to output single data file for the writes in the whole block, since we can't distinguish writes from different stage of abci events.

It adds new config items for file streamer:
- streamers.file.output-metadata
- streamers.file.stop-node-on-error
- streamers.file.fsync

synchronous abci call, and format doc

fix comment

update file streamer readme and fix typos

typo

* improve UX of file streamer, make it immediately usable after enabled

- set default value to write_dir.
- make write_dir based on home directory by default.
- auto-create the directory if not exists.

* get homePage from opts

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-12-02 15:43:21 +01:00
Jeancarlo Barrios
754ca3169e
feat: add tx limit to mempool (#14014)
* feat: add bounding max tx to mempool

* add bounded condition

* sligh improvement on generator

* remove unbouded option

* add test

* added mempool options mechanism

* mising test

* seting mempool

* change function name

* change function name

* failing test

* Revert "failing test"

This reverts commit d527982b0d4ec826ff680afb8f43ac1d71809ccf.

* fix import block

* changelog entries

* add ability to do unbounded mempool

* remove unesesary variable

* small comments

* change 0 to mean unbounded

* t

* small test fix

* add the ability to be bounded unbounded and disabled

* t

* set default maxtx

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* example for opts

* remove superflues logs entry

* add mempool to configurations

* fix more understandable name

* remove table in favor of bulletpoints

* sender nonce to unbounded

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update types/mempool/sender_nonce.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update types/mempool/sender_nonce.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update docs/docs/building-apps/02-app-mempool.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update server/config/config.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* t

* add comment for options

* fix inport

* fix inport

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
2022-12-02 00:39:55 +00:00
Aleksandr Bezobchuk
9f46665d93
chore: Test for Server Config Read #14125 2022-12-01 21:18:33 +00:00
Julián Toledano
6679ee0eea
fix: remove rosetta from server start (#14062)
* delete: rosetta from server start

* update: go.sum

* CHANGELOG

* update: changelog
2022-11-30 19:16:56 +00:00
Julien Robert
f96072d9a8
fix: do not shadow clientCtx in start.go (#14086) 2022-11-30 12:26:20 +00:00
Marko
2e3d38f01c
refactor: move snapshotstore under store (#14048)
* Move snapshotstore under store

* add changelog entry

* fix build

* move snapshot proto package

* make proto-gen

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
2022-11-29 23:40:14 +00:00
Julien Robert
6f329d70c6
docs: add docs about x/auth/tx (#14021)
* docs: add docs about `x/auth/tx`

* updates

* updates

* updates

* updates

* updates

* updates

* updates

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-11-27 20:30:23 +00:00