When testing with -race, sometimes the random source generate the same
string for consecutive calls, causing duplicated voter address. So the
number of votes in DB is not 20.
To fix this, we ensure unique addresses are generated, by using a map
for tracking which one was produced, and skip the duplicated address and
generated new one. Testing with:
go test -race -v -count=1000 -run=TestPaginatedVotesQuery
now passes.
Updates #9010
* Updates to Genesis
* Move grpc_query tests to keeper pkg
* Unify CLI command usage message
* Use timestamp for time based expiration in cli
* Update FlagExpiration
* Update wording
* Add test case for invalid expiration
* Update cli Long description
* Update exp date examples
* Use constants
* Set proper default command output
* Removed duplicated cmd.SetErr(cmd.ErrOrStderr()) and cmd.SetOut(cmd.OutOrStdout())
* Moved command initialization and added CHANGELOG
* fix: groom all uses of cmd.Print*
* Ran make format
Co-authored-by: Michael FIG <mfig@agoric.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
addrLen is encoded in a byte, so it's an uint8. The code in
AddressFromBalancesStore cast it to int for bound checking, but wrongly uses "addrLen+1", which can be overflow.
To fix this, just cast addrLen once and use it in all places.
Found by fuzzing added in #9060.
Fixes#9111
Delegations and undelegations calculations performed during
accounting operations for vesting accounts were correct but
were not written back to the account store.
closes: #8601closes: #8812
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com>
Co-authored-by: Adam Bozanich <adam.boz@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Currently, AddressFromBalancesStore uses the input key without any
validation, so an empty key or an invalid key length cause it panics.
This commit fixes the problem, by returning an error in case of invalid
key was passed.
Found by fuzzing added in #9060.
Fixed#9062
* Overview of keepers in object capability model (OCM)
* Updates to the spec, making clarifications
* Create a sequence diagram of a (fresh) delegation
* Misc notes, not yet decided where to put them
* Description of the shares abstraction in validators
* Model all keeper dependencies and move the UML file to docs
* Move and rename delegation sequence diagram
* Move shares description
* Remove TODO
* Diagram touch-ups
* Add how consensus power is calculated
* remove temp file
* Diagram improvements
* Describe slashing in more detail
* Describe redelegation
* Describe unbonding
* Delegation updates
* Delegation updates
* Make a diagram describing overall transaction flow
* Add delegation flows for the events of tokens being bonded/unbonding/etc.
* Grammar fix
* Diagram updates: distinguish alts, remove numbering.
* Use groups instead of "func:" participants
* Remove unused keepers from dependency diagram
* Add title to unbonding diagram
* Move keeper dependencies
* small doc updates
* remove numbers on sequence diagram
* !!!WIP EndBlock
* Explain "Last"-prefix in storage
* Remove `panic` step (they are supposed to never happen)
* EndBlock sequence diagram (with TODOs)
* Add TODO
* More visible TODOs
* Remove numbering
* Complete EndBlock
* Remove numbering
* Remove TODOs and update title
* add title back
* remove endblock seq-diagram
* Make power index update conditional on not being jailed
* update title
* Move files to /docs
* Install PlantUML and compile images to png and txt
* Use transaction flow in documentation
* Use staking UML in staking docs
* Clarify uml with inline doc
* Add keeper deps diagram to docs
* Only produce SVG images
Co-authored-by: hjort <>
Co-authored-by: Marko <marbar3778@yahoo.com>
* -added consensus version tracking to x/upgrade
* -added interface to module manager -added e2e test for migrations using consensus version store in x/upgrade -cleaned up x/upgrade Keeper -handler in apply upgrade now handles errors and setting consensus versions -cleaned up migration map keys -removed init chainer method -simapp now implements GetConsensusVersions to assist with testing
* protocol version p1
* add protocol version to baseapp
* rebase against master
* add test
* added test case
* cleanup
* docs and change to bigendian
* changelog
* cleanup keeper
* swap appVersion and version
* cleanup
* change interface id
* update keeper field name to versionSetter
* reorder keys and docs
* -move interface into exported folder
* typo
* typo2
* docs on keeper fields
* docs for upgrade NewKeeper
* cleanup
* NewKeeper docs
Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
* Make clearer that the distribution iterates over all active validators, not just ones that voted
* Update x/distribution/keeper/allocation.go
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
* Move comment to docstring
* Change variable name
* Fix: remove git conflict markers
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
* First run
* Remove dead code
* Make test pass
* Proto gen
* Fix lint
* Add changelog
* Fix tests
* Fix test
* Update x/auth/tx/service.go
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
* Remove protoTxProvider
* Add grpc-gateway test
* Add comment
* move to api breaking
* lesser diff
* remove conflict
* empty commit to rerun CI
* empty commit to rerun CI
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* update MsgCreateValidator ValidateBasic to enforce self delegation minimum
MsgCreateValidator ValidateBasic requires a self delegation of at least one consensus power, this prevents a common, but hard to debug error
* add changelog
* Update CHANGELOG.md
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* fix simulation tests
Construct successfuly MsgCreateValidator to use a self delegation which is greater than the PowerReduction
* fix cli tests
* fix cli tests
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* -added consensus version tracking to x/upgrade
* -added interface to module manager -added e2e test for migrations using consensus version store in x/upgrade -cleaned up x/upgrade Keeper -handler in apply upgrade now handles errors and setting consensus versions -cleaned up migration map keys -removed init chainer method -simapp now implements GetConsensusVersions to assist with testing
* Changed MigrationMap identifier to VersionMap
removed module_test
* updated docs
* forgot this
* added line to changelog for this PR
* Change set consensus version function to match adr 041 spec
* add documentation
* remove newline from changelog
unnecessary newline removed
* updated example in simapp for RunMigrations, SetCurrentConsensusVersions now returns an error
* switch TestMigrations to use Require instead of t.Fatal
* Update CHANGELOG.md
Co-authored-by: Aaron Craelius <aaron@regen.network>
* docs for SetVersionManager
* -init genesis method added -removed panics/fails from setting consensus versions
* update identifiers to be more go-like
* update docs and UpgradeHandler fnc sig
* Upgrade Keeper now takes a VersionMap instead of a VersionManager interface
* upgrade keeper transition to Version Map
* cleanup, added versionmap return to RunMigrations
* quick fix
* Update docs/architecture/adr-041-in-place-store-migrations.md
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
* remove support for versionmap field on upgrade keeper
* cleanup
* rename get/set version map keeper functions
* update adr doc to match name changes
* remove redudant line
Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Overview of keepers in object capability model (OCM)
* Updates to the spec, making clarifications
* Create a sequence diagram of a (fresh) delegation
* Misc notes, not yet decided where to put them
* Description of the shares abstraction in validators
* Model all keeper dependencies and move the UML file to docs
* Move and rename delegation sequence diagram
* Move shares description
* Remove TODO
* Diagram touch-ups
* Add how consensus power is calculated
* remove temp file
* Diagram improvements
* Describe slashing in more detail
* Describe redelegation
* Describe unbonding
* Delegation updates
* Delegation updates
* Make a diagram describing overall transaction flow
* Add delegation flows for the events of tokens being bonded/unbonding/etc.
* Grammar fix
* Diagram updates: distinguish alts, remove numbering.
* Use groups instead of "func:" participants
* Remove unused keepers from dependency diagram
* Add title to unbonding diagram
* Move keeper dependencies
* small doc updates
* remove numbers on sequence diagram
* !!!WIP EndBlock
* Explain "Last"-prefix in storage
* Remove `panic` step (they are supposed to never happen)
* EndBlock sequence diagram (with TODOs)
* Add TODO
* More visible TODOs
* Remove numbering
* Complete EndBlock
* Remove numbering
* Remove TODOs and update title
* add title back
* remove endblock seq-diagram
* spec updates
* Make power index update conditional on not being jailed
* update title
* Delete sequnce diagrams
* Fix tokens to consensus power ratio
* Fix type
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: hjort <>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* remove time based upgrades
* cleanup
* cleanup evidence of time based upgrades
* cleanup docs referring to time based upgrades
* forgot one
* added line to changelog deprecated section
* Update proto/cosmos/upgrade/v1beta1/upgrade.proto
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
* update changelog line to correct section
* update buf config to allow reserved fields
Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
* Skips very noisy benchmarks that end up running only for b.N=1 because
their entire time is spent in setup, and varying parameters doesn't change
much given that the number of stores is what dominates the expense. To
ensure we can provide reliable benchmarks, progressively for the project,
skip these until there is a proper re-work of what the benchmarks need to do
* Previously sub-benchmarks: b.Run(...) did not b.ReportAllocs() due to a faulty
assumption that invoking b.ReportAllocs() at the top would be inherited by
all sub-benchmarks. This change fixes that
Fixes#8779Fixes#8855
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Move all migration scripts to v043
* Fix permaling
* Fix test
* Fix test again
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add back supply proto
* Add migration for supply
* Fix lint
* Update x/bank/spec/01_state.md
* Fix test
* Proto gen
* Update x/bank/spec/01_state.md
* Make proto gen
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
* enable secp256r1 in antehandlers
* Add sig verification benchamrk to find a sigverify fee
* adjust the gas fee
* enable secp256r1 in antehandlers
* Add sig verification benchamrk to find a sigverify fee
* adjust the gas fee
* Update the secp256r1 fee factor
* Update changelog
* regenerate docs
This benchmark examines how ValidateGenesis behaves.
In a follow-up issue, I'll show how it reveals an inefficiency
that'll affect trying to load repeatedly retrieve Validators'
ConsAddress values.
Updates #8744
* add zeroed custom fields check to tm client
* remove custom fields function from x/upgrade and fix tests
* use []byte in x/upgrade, move abci to 02-client
* remove x/ibc from types
* whoops, delete testing files
* fix upgrade tests
* fix tm tests
* fix tests
* update CHANGELOG
* revert proto breakage, use reserved field cc @amaurym
* add IBC Upgrade Proposal type
* remove IBC from upgrade types
* add IBC upgrade logic to 02-client
* fix all tests for x/upgrade
* Add CLI for IBC Upgrade Proposal
* Update x/ibc/core/02-client/types/proposal_test.go
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* add gRPC for upgraded client state
* test fixes
* add HandleUpgradeProposal tests
* update docs and remove unnecessary code
* self review bug and test fixes
* neatness
* construct empty rest handler
* fix tests
* fix stringer tests
* Update docs/core/proto-docs.md
Co-authored-by: Christopher Goes <cwgoes@pluranimity.org>
* add key in ibc store tracking ibc upgrade heights
Add a new Key to the IBC client store to track the IBC Upgrade Height. This allows IBC upgrades to correctly remove old IBC upgrade states
* update abci and tests
* revert key storage after discussion with @AdityaSripal
Revert using a key to track IBC upgrades. By clearing any IBC state using an old plan in ScheduleUpgrade, IBC upgrades do not need to be tracked by IBC. This reduces code complexity and reduces potential for bugs.
* clear IBC states on cancelled upgrades
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Christopher Goes <cwgoes@pluranimity.org>
* Use x/auth/client for querying Txs
* Fix lint
* Fix small test
* Update todos
* Move QueryTx functions to x/auth/tx
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
* Consolidating codec.go registrations. Moving Acknowledgement result/error to its own file
* Updating CHANGELOG.md with #7949 improvement as requested
* revert removing acknowledgement proto to its own file
* update changelog
* remove unnecessary pb.go file
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
After continuously profiling InitGensis with 100K accounts, it showed
pathologically slow code, that was the result of a couple of patterns:
* Unconditional and not always necessary map lookups
* O(n^2) sdk.AccAddressFromBech32 retrievals when the code is expensive,
during a quicksort
The remedy involved 4 parts:
* O(n) sdk.AccAddressFromBech32 invocations, down from O(n^2) in the quicksort
* Only doing map lookups when the domain key check has passed
* Using a black magic compiler technique of the map clearing idiom
* Zero allocation []byte<->string conversion
With 100K accounts, this brings InitGenesis down to ~6min, instead of
20+min, it reduces the sort code from ~7sec down to 50ms.
Also some simple benchmark reflect the change:
```shell
name old time/op new time/op delta
SanitizeBalances500-8 19.3ms ±10% 1.5ms ± 5% -92.46% (p=0.000 n=20+20)
SanitizeBalances1000-8 41.9ms ± 8% 3.0ms ±12% -92.92% (p=0.000 n=20+20)
name old alloc/op new alloc/op delta
SanitizeBalances500-8 9.05MB ± 6% 0.56MB ± 0% -93.76% (p=0.000 n=20+18)
SanitizeBalances1000-8 20.2MB ± 3% 1.1MB ± 0% -94.37% (p=0.000 n=20+19)
name old allocs/op new allocs/op delta
SanitizeBalances500-8 72.4k ± 6% 4.5k ± 0% -93.76% (p=0.000 n=20+20)
SanitizeBalances1000-8 162k ± 3% 9k ± 0% -94.40% (p=0.000 n=20+20)
```
The CPU profiles show the radical change as per
https://github.com/cosmos/cosmos-sdk/issues/7766#issuecomment-786671734
Later on, we shall do more profiling and fixes but for now this brings
down the run-time for InitGenesis.
Fixes#7766
Co-authored-by: Alessio Treglia <alessio@tendermint.com>