## Description
The `init` method of the `Rand` struct was called twice: in the constructor and in the `init` function.
Closes: #XXXX
---
### 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)
## Description
Ref: https://github.com/cosmos/cosmos-sdk/issues/15170
Included in: #15515
Required to resolve a discrepancy between the sign mode being implemented in #15170 and the existing legacy one.
When calling tx builder [SetMsgs](4a6a1e3cb8/x/auth/tx/builder.go (L208)) messages are coerced to an any type in [NewAnyWithValue](4a6a1e3cb8/codec/types/any.go (L61)). This marshals a message as proto bytes. If a message has cosmos.Dec typed fields, and they are set to nil, the will be set to 0 during seriazliation in the [Dec.Marshal](88909d6f2b/math/dec.go (L801)) implementation.
This side effect *changes* the output of a JSON marshal before and after the call to Dec.Marshal, as shown below.
```go
rates := &stakingtypes.CommissionRates{}
MarshalJson(rates)
// {"rate":"0","max_rate":"0","max_change_rate":"0"}
MarshalProto(rates)
MarshalJson(rates)
//{"rate":"0.000000000000000000","max_rate":"0.000000000000000000","max_change_rate":"0.000000000000000000"}
```
An integration is test is also committed asserting the (now fixed) behavior above. Its asserts should be changed once a release of math is made and `/tests/go.mod` is updated.
---
### 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)
Optimizes and tests FormatInt by removing inefficient string
concatenation but also making it so much clearer with how one would
express adding thousand separators in natural language. It uses
a combination of strings.Builder whose values can be grown
The performance improvement is stark in every dimension:
```shell
$ benchstat before.txt after3.txt
name old time/op new time/op delta
DecimalValueRendererFormat-8 4.48µs ± 1% 2.11µs ± 2% -52.90% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
DecimalValueRendererFormat-8 3.62kB ± 0% 0.78kB ± 0% -78.59% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
DecimalValueRendererFormat-8 83.0 ± 0% 28.0 ± 0% -66.27% (p=0.000 n=10+10)
```
While here, also simplified zero padding for LegacyNewDecFromStr
simply by using strings.Repeat instead of a convoluted
fmt.Sprintf+strconv.Itoa.
Fixes#14008Fixes#14003
Co-authored-by: Marko <marbar3778@yahoo.com>
* refactor: Move FormatCoins to `core`
* Rename to shorter names
* Add chaneglog
* Don't panic
* add comments
* go mod tidy
* fix changelog
* move structs to top
* Fix test
* go mod tidy
* Refactor tests
* go workspaces
* tidy
* catch all 11 modules
* go.mod no longer replaces modules in the sdk
* correct ics23 import
* indirect in indirect list
* fix cosmovisor
## Description
---
### 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/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)
The specification of "copy", the builtin function per
https://pkg.go.dev/builtin#copy, says that it returns the minimum of
len(src) and len(dst) when invoked as:
copy(dst, src)
of which the prior code blindly assumed that everytime that
copy is invoked that the buffer provided had enough size
to accomodate the contents of *.MarshalTo but this isn't true
at all if len(data) is less than the values of .Marshal()
This change adds a negative value check to Uint.Unmarshal,
which coincidentally is fixed by refactoring for code reuse.
While here, added tests to ensure we don't regress.
Fixes#11995