Skip to content

Commit 8a9589a

Browse files
style: lint go and markdown (backport #10060) (#10473)
* style: lint go and markdown (#10060) ## Description + fixing `x/bank/migrations/v44.migrateDenomMetadata` - we could potentially put a wrong data in a new key if the old keys have variable length. + linting the code Putting in the same PR because i found the issue when running a linter. Depends on: #10112 --- ### 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] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/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) (cherry picked from commit 479485f) # Conflicts: # CODING_GUIDELINES.md # CONTRIBUTING.md # STABLE_RELEASES.md # contrib/rosetta/README.md # cosmovisor/README.md # crypto/keyring/keyring.go # db/README.md # docs/404.md # docs/DOCS_README.md # docs/architecture/adr-038-state-listening.md # docs/architecture/adr-040-storage-and-smt-state-commitments.md # docs/architecture/adr-043-nft-module.md # docs/architecture/adr-044-protobuf-updates-guidelines.md # docs/architecture/adr-046-module-params.md # docs/migrations/pre-upgrade.md # docs/migrations/rest.md # docs/ru/README.md # docs/run-node/rosetta.md # docs/run-node/run-node.md # docs/run-node/run-testnet.md # go.mod # scripts/module-tests.sh # snapshots/README.md # store/streaming/README.md # store/streaming/file/README.md # store/v2/flat/store.go # store/v2/smt/store.go # x/auth/ante/sigverify.go # x/auth/middleware/basic.go # x/auth/spec/01_concepts.md # x/auth/spec/05_vesting.md # x/auth/spec/07_client.md # x/authz/spec/05_client.md # x/bank/spec/README.md # x/crisis/spec/05_client.md # x/distribution/spec/README.md # x/epoching/keeper/keeper.go # x/epoching/spec/03_to_improve.md # x/evidence/spec/07_client.md # x/feegrant/spec/README.md # x/gov/spec/01_concepts.md # x/gov/spec/07_client.md # x/group/internal/orm/spec/01_table.md # x/mint/spec/06_client.md # x/slashing/spec/09_client.md # x/slashing/spec/README.md # x/staking/spec/09_client.md # x/upgrade/spec/04_client.md * fix conflicts * remove unnecessary files Co-authored-by: Robert Zaremba <[email protected]>
1 parent 0ac1f6d commit 8a9589a

File tree

38 files changed

+5745
-374
lines changed

38 files changed

+5745
-374
lines changed

CODING_GUIDELINES.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Coding Guidelines
2+
3+
This document is an extension to [CONTRIBUTING](./CONTRIBUTING.md) and provides more details about the coding guidelines and requirements.
4+
5+
## API & Design
6+
7+
+ Code must be well structured:
8+
+ packages must have a limited responsibility (different concerns can go to different packages),
9+
+ types must be easy to compose,
10+
+ think about maintainbility and testability.
11+
+ "Depend upon abstractions, [not] concretions".
12+
+ Try to limit the number of methods you are exposing. It's easier to expose something later than to hide it.
13+
+ Take advantage of `internal` package concept.
14+
+ Follow agreed-upon design patterns and naming conventions.
15+
+ publicly-exposed functions are named logically, have forward-thinking arguments and return types.
16+
+ Avoid global variables and global configurators.
17+
+ Favor composable and extensible designs.
18+
+ Minimize code duplication.
19+
+ Limit third-party dependencies.
20+
21+
Performance:
22+
23+
+ Avoid unnecessary operations or memory allocations.
24+
25+
Security:
26+
27+
+ Pay proper attention to exploits involving:
28+
+ gas usage
29+
+ transaction verification and signatures
30+
+ malleability
31+
+ code must be always deterministic
32+
+ Thread safety. If some functionality is not thread-safe, or uses something that is not thread-safe, then clearly indicate the risk on each level.
33+
34+
## Testing
35+
36+
Make sure your code is well tested:
37+
38+
+ Provide unit tests for every unit of your code if possible. Unit tests are expected to comprise 70%-80% of your tests.
39+
+ Describe the test scenarios you are implementing for integration tests.
40+
+ Create integration tests for queries and msgs.
41+
+ Use both test cases and property / fuzzy testing. We use the [rapid](pgregory.net/rapid) Go library for property-based and fuzzy testing.
42+
+ Do not decrease code test coverage. Explain in a PR if test coverage is decreased.
43+
44+
We expect tests to use `require` or `assert` rather than `t.Skip` or `t.Fail`,
45+
unless there is a reason to do otherwise.
46+
When testing a function under a variety of different inputs, we prefer to use
47+
[table driven tests](https://github.com/golang/go/wiki/TableDrivenTests).
48+
Table driven test error messages should follow the following format
49+
`<desc>, tc #<index>, i #<index>`.
50+
`<desc>` is an optional short description of whats failing, `tc` is the
51+
index within the test case table that is failing, and `i` is when there
52+
is a loop, exactly which iteration of the loop failed.
53+
The idea is you should be able to see the
54+
error message and figure out exactly what failed.
55+
Here is an example check:
56+
57+
```go
58+
<some table>
59+
for tcIndex, tc := range cases {
60+
<some code>
61+
resp, err := doSomething()
62+
require.NoError(err)
63+
require.Equal(t, tc.expected, resp, "should correctly perform X")
64+
```
65+
66+
## Quality Assurance
67+
68+
We are forming a QA team that will support the core Cosmos SDK team and collaborators by:
69+
70+
- Improving the Cosmos SDK QA Processes
71+
- Improving automation in QA and testing
72+
- Defining high-quality metrics
73+
- Maintaining and improving testing frameworks (unit tests, integration tests, and functional tests)
74+
- Defining test scenarios.
75+
- Verifying user experience and defining a high quality.
76+
- We want to have **acceptance tests**! Document and list acceptance lists that are implemented and identify acceptance tests that are still missing.
77+
- Acceptance tests should be specified in `acceptance-tests` directory as Markdown files.
78+
- Supporting other teams with testing frameworks, automation, and User Experience testing.
79+
- Testing chain upgrades for every new breaking change.
80+
- Defining automated tests that assure data integrity after an update.
81+
82+
Desired outcomes:
83+
84+
- QA team works with Development Team.
85+
- QA is happening in parallel with Core Cosmos SDK development.
86+
- Releases are more predictable.
87+
- QA reports. Goal is to guide with new tasks and be one of the QA measures.
88+
89+
As a developer, you must help the QA team by providing instructions for User Experience (UX) and functional testing.

CONTRIBUTING.md

Lines changed: 113 additions & 205 deletions
Large diffs are not rendered by default.

STABLE_RELEASES.md

Lines changed: 0 additions & 143 deletions
This file was deleted.

contrib/rosetta/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ Contains the required files to set up rosetta cli and make it work against its w
1717

1818
## node
1919

20-
Contains the files for a deterministic network, with fixed keys and some actions on there, to test parsing of msgs and historical balances.
20+
Contains the files for a deterministic network, with fixed keys and some actions on there, to test parsing of msgs and historical balances. This image is used to run a simapp node and to run the rosetta server.
21+
22+
## Rosetta-cli
23+
24+
The docker image for ./rosetta-cli/Dockerfile is on [docker hub](https://hub.docker.com/r/tendermintdev/rosetta-cli). Whenever rosetta-cli releases a new version, rosetta-cli/Dockerfile should be updated to reflect the new version and pushed to docker hub.
2125

2226
## Notes
2327

crypto/keys/multisig/amino.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func tmToProto(tmPk tmMultisig) (*LegacyAminoPubKey, error) {
6464
}
6565

6666
// MarshalAminoJSON overrides amino JSON unmarshaling.
67-
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) { //nolint:golint
67+
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) { //nolint:revive
6868
return protoToTm(&m)
6969
}
7070

crypto/keys/secp256k1/secp256k1_nocgo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !libsecp256k1
12
// +build !libsecp256k1
23

34
package secp256k1

crypto/ledger/ledger_notavail.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
//go:build !cgo || !ledger
12
// +build !cgo !ledger
3+
24
// test_ledger_mock
35

46
package ledger

docs/404.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!--
2+
permalink: /404.html
3+
layout: homepage
4+
title: 404 Lost in Space!
5+
description: You've been lost in space
6+
sections:
7+
- title: Introduction
8+
desc: High-level overview of the Cosmos SDK.
9+
url: /intro/overview.html
10+
icon: introduction
11+
- title: Basics
12+
desc: Anatomy of a blockchain, transaction lifecycle, accounts and more.
13+
icon: basics
14+
url: /basics/app-anatomy.html
15+
- title: Core Concepts
16+
desc: Read about the core concepts like baseapp, the store, or the server.
17+
icon: core
18+
url: /core/baseapp.html
19+
- title: Building Modules
20+
desc: Discover how to build modules for the Cosmos SDK.
21+
icon: modules
22+
url: /building-modules/intro.html
23+
- title: Running a Node
24+
desc: Running and interacting with nodes using the CLI and API.
25+
icon: interfaces
26+
url: /run-node/
27+
- title: Modules
28+
desc: Explore existing modules to build your application with.
29+
icon: specifications
30+
url: /modules/
31+
stack:
32+
- title: Cosmos Hub
33+
desc: The first of thousands of interconnected blockchains on the Cosmos Network.
34+
color: "#BA3FD9"
35+
label: hub
36+
url: http://hub.cosmos.network
37+
- title: Tendermint Core
38+
desc: The leading BFT engine for building blockchains, powering Cosmos SDK.
39+
color: "#00BB00"
40+
label: core
41+
url: http://docs.tendermint.com
42+
footer:
43+
newsletter: false
44+
aside: false
45+
-->
46+
47+
# 404 - Lost in space, this is just an empty void

docs/DOCS_README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# Updating the docs
22

3-
If you want to open a PR on the Cosmos SDK to update the documentation, please follow the guidelines in the [`CONTRIBUTING.md`](https://github.com/cosmos/cosmos-sdk/tree/master/CONTRIBUTING.md#updating-documentation)
4-
5-
## Translating
6-
7-
- Docs translations live in a `docs/country-code/` folder, where `country-code` stands for the country code of the language used (`cn` for Chinese, `kr` for Korea, `fr` for France, ...).
8-
- Always translate content living on `master`.
9-
- Only content under `/docs/intro/`, `/docs/basics/`, `/docs/core/`, `/docs/building-modules/` and `docs/run-node/` needs to be translated, as well as `docs/README.md`. It is also nice (but not mandatory) to translate `/docs/spec/`.
10-
- Specify the release/tag of the translation in the README of your translation folder. Update the release/tag each time you update the translation.
3+
If you want to open a PR in Cosmos SDK to update the documentation, please follow the guidelines in [`CONTRIBUTING.md`](https://github.com/cosmos/cosmos-sdk/tree/master/CONTRIBUTING.md#updating-documentation).
4+
5+
## Internationalization
6+
7+
- Translations for documentation live in a `docs/<locale>/` folder, where `<locale>` is the language code for a specific language. For example, `zh` for Chinese, `ko` for Korean, `ru` for Russian, etc.
8+
- Each `docs/<locale>/` folder must follow the same folder structure within `docs/`, but only content in the following folders needs to be translated and included in the respective `docs/<locale>/` folder:
9+
- `docs/basics/`
10+
- `docs/building-modules/`
11+
- `docs/core/`
12+
- `docs/ibc/`
13+
- `docs/intro/`
14+
- `docs/migrations/`
15+
- `docs/run-node/`
16+
- Each `docs/<locale>/` folder must also have a `README.md` that includes a translated version of both the layout and content within the root-level [`README.md`](https://github.com/cosmos/cosmos-sdk/tree/master/docs/README.md). The layout defined in the `README.md` is used to build the homepage.
17+
- Always translate content living on `master` unless you are revising documentation for a specific release. Translated documentation like the root-level documentation is semantically versioned.
18+
- For additional configuration options, please see [VuePress Internationalization](https://vuepress.vuejs.org/guide/i18n.html).
1119

1220
## Docs Build Workflow
1321

docs/architecture/adr-010-modular-antehandler.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,6 @@ Cons:
273273
1. Decorator pattern may have a deeply nested structure that is hard to understand, this is mitigated by having the decorator order explicitly listed in the `ChainAnteDecorators` function.
274274
2. Does not make use of the ModuleManager design. Since this is already being used for BeginBlocker/EndBlocker, this proposal seems unaligned with that design pattern.
275275

276-
## Status
277-
278-
> Accepted Simple Decorators approach
279-
280276
## Consequences
281277

282278
Since pros and cons are written for each approach, it is omitted from this section

0 commit comments

Comments
 (0)