Commit Graph

7916 Commits

Author SHA1 Message Date
colin axnér da064e13d5
Remove IBC from the SDK (#8735) 2021-03-04 13:11:34 +00:00
Robert Zaremba c66f1f7efe
crypto: add secp256r1 (#8559)
* Optimize secp256k1 hashing

* Add ADR-028 related functions

* Update ed25519

* fix errors/handle

* fix build

* fix build

* Add tests and update function names

* wip

* Use LengthPrefix for composed addresses

* add tests for NewComposed

* add module hash function

* fix append

* rollback ed25519 ADR-28 update

* rollback ed25519 ADR-28 test

* Adding Module tests and convert tests to test suite

* convert store_key_test.go to test suite

* rollback test check comment

* any.pb.go update

* generated proto files

* wip

* renames

* wip2

* add String method to PBBytes

* wip3

* add pubkey tests

* adding cryptotypes.PrivKey methods

* re-enable test

* fix equals test

* fix ecdsa object receiver

* add ProtoMarshaler implementation and tests

* move code to init and add interface registry

* add bytes tests

* merge Unmarshal with UnmarshalAmino

* implement ProtoMarshaler to ecdsaSK

* remove bytes.go

* add private key marshaling tests

* break tests into 2 suites

* add signature tests

* remove TODO

* remove bytes.proto

* adding changelog

* Update CHANGELOG.md

* Update crypto/keys/ecdsa/ecdsa_privkey.go

* Update crypto/keys/ecdsa/ecdsa_pubkey.go

* comments: add dot (.) at the end

* update comments

* update commented code

* rename files

* remove Amino methods

* use 2 spaces in protocgen.sh

* rollback changes in protocgen.sh

* add MessageName

* rework ecdsa proto structure

* move ecdsa to internal package

* add secp256r1 proto

* refactore proto definition for secp256r1

* fix err check

* update comments

* create const for fieldSize+1

* simplify the PubKey.String test

* Apply suggestions from code review

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>

* Update doc comments: SDK Interface -> sdk.Interface

* rename init.go to doc.go

* Add PubKey.Type() test

* Revert "Update doc comments: SDK Interface -> sdk.Interface"

This reverts commit 01f2b4f5efcd79a452483bcda152db54a8fbfee2.

* Use cryptotypes.Address instead of tmcrypto

* Revert "Use cryptotypes.Address instead of tmcrypto"

This reverts commit 15b866ae67bdb7ca4872f4089fcab19f9e2e3608.
This issue will be solved in https://github.com/cosmos/cosmos-sdk/issues/8775

* add link to ANSI X9.62

* move init.go -> doc.go

* use proto.MessageName()

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
2021-03-04 12:29:48 +00:00
Amaury eef8d4dc5d
Fix typo in querying events (#8773) 2021-03-03 18:13:16 +00:00
Alessio Treglia be48479310
update changelog against v0.41.4 (#8771) 2021-03-03 17:09:18 +00:00
colin axnér a9b034b5f3
Emit header in MsgUpdateClient events (#8624)
* emit header in update client msg

* update CHANGELOG

* update spec

* fix nil header bug

* use JSON encoding for emitting header

* Update x/ibc/core/spec/06_events.md

* use proto for encoding

* add tests

* encode to hex before emitting header in event

* add comment addressing reasoning for hex encoding

* Update CHANGELOG.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2021-03-03 16:40:05 +00:00
Alessio Treglia a556783248
build with go1.16 (#8768) 2021-03-03 16:27:35 +00:00
Robert Zaremba 0b6833c333
Lock mutex on getting element from cache (#8767) 2021-03-03 15:52:38 +00:00
Cuong Manh Le 91affb5167
simapp, types: fix benchmarks panics by honoring skip if set (#8763)
- BenchmarkAccAddressString must initialize the index less than ed25519.PubKeySize to avoid panics
 - BenchmarkFullAppSimulation should be skipped as it has the same logic as tests

Fixes #8762
2021-03-03 03:54:14 -08:00
SaReN eb8aaf9395
Index supply by denom (#8517)
* temp commit

* remove supply

* update tests

* revert proto script

* fix lint

* update tests

* remove decoder

* fix lint

* update set supply

* add changelog

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
2021-03-03 09:58:16 +00:00
Robert Zaremba 2864eb69a3
Robert/addr memory leak (#8717)
* address: adding cache address.String() cache benchmark

* address: use LRU cache for .String()

* optimize address.Empty

* move cache initialization to init function

* Use UnsafeBytesToStr convertion with Addr cache

* add cache for other address String() methods

* fix linter issue

* add a non trivial address for Address.String benchmark

* add comment about cache size and update cashe size to 60k

* fix syntax

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-03-03 03:53:28 +00:00
Amaury 30f58b5662
Weighted votes migrate in-place migrations (#8663)
* Weighted votes migrate in-place migrations

* Rename to pb.go

* Fix some lint

* Fix lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-03-02 22:22:02 +00:00
Marko 810605689d
further reduce logging (#8752) 2021-03-02 15:39:46 +00:00
Cuong Manh Le a193522f7e
crypto/keys/internal: use crypto/rand.Reader for generating private key (#8742)
genPrivKey rejects invalid fieldelems, so we must use a real reader
instead of the zero reader.

Fixes #8741
2021-03-02 01:56:51 -08:00
Emmanuel T Odeke 585ffd6cff
x/staking: add ValidateGenesis benchmark (#8746)
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
2021-03-02 01:01:05 -08:00
Alessio Treglia 010eeef457
Rename InfoImporter -> LegacyInfoImporter (#8739)
Avoid namespace clash with the InfoImporter interface
that already exists in the v0.41 release series.
2021-03-01 20:09:01 +00:00
colin axnér 1c6e267964
Remove IBC logic from x/upgrade (#8673)
* 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>
2021-03-01 16:28:54 +00:00
Amaury a93edeef4c
Move QueryTx functions to x/auth/tx (#8734)
* 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>
2021-03-01 15:57:28 +00:00
Robert Zaremba 5f2b90c3c7
internal: create package for unsafe bytes convertion (#8733)
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-03-01 15:10:22 +00:00
Damian Nolan 0792db78b8
minor channel fixes (#8665)
* 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>
2021-03-01 15:13:37 +01:00
Amaury 3832860263
Allow REST endpoint to query txs with multisig (#8730)
* Fix unpack stdtx

* Add test for multisig

* remove println

* Add changelog

* Better UnpackInterfaces

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-03-01 13:01:05 +00:00
SaReN b1c72fda7f
crypto/keyring: fix offline keys migration (#8639)
Fix `keys migrate` command (#8703)

crypto/keyring: reinstate the InfoImporter interface

InfoImporter is implemented by those Keyring implementations
that support import of Info objects.

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
2021-03-01 12:41:49 +00:00
Robert Zaremba 32f454aa10
Makefile: fix build_tags update (#8725)
Previously, we set build_tags before updating the options for DB backend.
This does't work with BadgerDB - it BUILD_TAGS which must be included in build_tags.

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-03-01 08:31:09 +00:00
dependabot[bot] 0bec60e39f
build(deps): bump github.com/prometheus/common from 0.17.0 to 0.18.0 (#8727)
Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/prometheus/common/releases)
- [Commits](https://github.com/prometheus/common/compare/v0.17.0...v0.18.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-01 08:27:13 +00:00
Sunny Aggarwal 1ba0d78fcb
Merge pull request #8569 from sikkatech/adr-epoched-staking
ADR Epoched Staking
2021-02-28 17:22:12 -05:00
Sunny Aggarwal c7da188b42
Merge branch 'master' into adr-epoched-staking 2021-02-28 16:48:22 -05:00
Emmanuel T Odeke dbb9923917
store/cachekv, x/bank/types: algorithmically fix pathologically slow code (#8719)
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>
2021-02-27 07:26:22 -08:00
Barrie Byron 68e7a3adf7
fix: per 8711 fix typo and minor command text edit for multi sign batch command (#8718)
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-27 09:39:08 +00:00
Dev Ojha a4ff0ef93e
Merge branch 'master' into adr-epoched-staking 2021-02-26 09:50:31 -06:00
Marko a786830bb4
auth: allow 0 coin accounts in genesis (#8714)
* allow zero accounts

* fix test

* fix test
2021-02-26 15:41:48 +00:00
Marko 2139212050
docker m1 (#8710) 2021-02-26 11:25:48 +00:00
Marko fd482a27bf
update ed25519 (#8690)
* update ed25519

* add changelog and doc.go

* add comment

* add note about tendermint
2021-02-26 10:09:05 +00:00
Segue 92bc2904d3
Fix legacy rest api (#8434) 2021-02-26 08:28:48 +00:00
Dev Ojha c0fd863ef1
Merge branch 'master' into adr-epoched-staking 2021-02-25 21:48:57 -06:00
Cory b19ac2c4f8
Add warning notice in changelog for v0.41.x bug (ref: #8461) (#8707)
* add disclaimer for v0.41 series for non-hub SDK chains due to #8461

* update issue link

* update issue link, pt2

* fix bad issue link
2021-02-25 16:48:21 -08:00
Robert Zaremba 70089844f7
scripts: indent multiline commands (#8706) 2021-02-25 20:57:41 +00:00
Frojdi Dymylja ef9968debd
[bank]: add balance tracking events (#8656)
* change(bank): add utxo events and simplify logic

* add(bank): balance and supply tracking test

* chore(bank): fix balance tracking test comment

* fix(grpc): service test

* fix(bank): sub unlocked coins to use less gas

* fix(auth): cli test gas

* fix(rest): grpc gas test

* fix(staking/cli): increase delegation required gas

* add: burn events, fix tests

* fix(auth/tx): grpc test

* add(bank): coin events in delegate

* fix(bank): add amt check in delegate coins back

* change(bank): add coin spent and coin recv events in burn and mint

* change(bank): revert sub coin function

* change(auth): revert cli test

* change(auth): revert service test

* chore(auth): fix events comment in service_test.go

* chore: update CHANGELOG.md

* remove(bank): balanceError func

* chore(bank): address lint warnings

* chore(bank): update events spec

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-02-25 18:15:02 +00:00
Amaury 19e79e00d6
ADR-019/020 cleanups: HybridCodec, Pubkey (#8683)
* wip adr019

* Remove hybrid codec

* Change date

* Update docs/architecture/adr-019-protobuf-state-encoding.md

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update pubkey interface

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-02-25 15:40:04 +00:00
Alessio Treglia 5d3f29b089
update tendermint to v0.34.8 (#8701) 2021-02-25 14:58:12 +00:00
Rikard Hjort d51875b07e
Updates and clarifications to the staking specs (#8675) 2021-02-25 14:42:41 +00:00
dependabot[bot] 96587cf3c2
build(deps): bump google.golang.org/grpc from 1.35.0 to 1.36.0 (#8696)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.35.0 to 1.36.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.35.0...v1.36.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-02-25 12:59:36 +00:00
Emmanuel T Odeke 929b62cd46
types: intern AccAddress.String() to gut wasted expensive recomputations (#8694)
Given that AccAddress is a []byte type, and its .String() method is
quite expensive, continuously invoking the method doesn't easily provide
a way for the result to be memoized. In memory profiles from
benchmarking OneBankSendTxPerBlock and run for a while, it showed >2GiB burnt
and SendCoins consuming a bunch of memory: >2GiB.

This change introduces a simple global cache with a map to intern
AccAddress values, so that we quickly look up the expensively computed
values. With it, the prior memory profiles are erased, and benchmarks
show improvements:

```shell
$ benchstat before.txt after.txt
name                     old time/op    new time/op    delta
OneBankSendTxPerBlock-8    1.94ms ± 9%    1.92ms ±11%   -1.34%  (p=0.011 n=58+57)

name                     old alloc/op   new alloc/op   delta
OneBankSendTxPerBlock-8     428kB ± 0%     365kB ± 0%  -14.67%  (p=0.000 n=58+54)

name                     old allocs/op  new allocs/op  delta
OneBankSendTxPerBlock-8     6.34k ± 0%     5.90k ± 0%   -7.06%  (p=0.000 n=58+57)
```

Fixes #8693

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-25 03:01:03 -08:00
Amaury ba74a7c737
x{stake,slash,gov,distrib} In-place Store Migrations (#8504)
* Add 1st version of migrate

* Put migration logic into Configurator

* add test to bank store migration

* add test for configurator

* Error if no migration found

* Remove RunMigrations from Configurator interface

* Update spec

* Rename folders

* copy-paste from keys.go

* Fix nil map

* rename function

* Update simapp/app.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update simapp/app_test.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Adderss reviews

* Fix tests

* Update testutil/context.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update docs for ConsensusVersion

* Rename to forVersion

* Fix tests

* Check error early

* Return 1 for intiial version

* Use MigrationKeeper

* Fix test

* Revert adding marshaler to Configurator

* Godoc updates

* Update docs

* Add distrib legacy folder

* Add tests for distrib migration

* Add gov migrations

* Copy paste whole keys file

* Add gov migrations

* Add staking

* Fix staking tests

* Update spec and module.go

* Update to latest changes

* Update migration scripts

* capability to 1

* Fix tests

* Add package godoc

* Remove whitespace

* Remove global

* Use Migrator

* Remove 042 keys files

* Fix build

* Unlambda

* Rename to Migrate1to2

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-02-25 10:43:31 +00:00
Amaury eeb3eabdc6
docs: Add mention to use gRPC v1.33.2 (#8658)
Co-authored-by: Marko <marbar3778@yahoo.com>
2021-02-25 07:57:06 +00:00
Kimura Yu 115096b09d
change dir '.appd' to '.app' (#8695) 2021-02-25 07:52:17 +00:00
Federico Kunze 149bed48fd
bank: name and symbol metadata fields (#8677)
* bank: name and symbol metadata fields

* cli test

* changelog
2021-02-24 20:06:04 -03:00
SaReN 77668a3c23
Add multisign batch command (#7787)
* initial commit

* update signing data

* Update signature

* code cleanup

* code cleanup

* Add test for ms batch

* update test

* add build flag

* update flags

* update tests

* add test for signbatch multisig

* update test

* fix sign batch multisig

* add test

* update offline usage

* update with sign batch fix

* fix lint

* update tests

* update test

* update tests

* fix signature only

* update seq

* fix conflicts

* update multisign

* revert unintended

* fix tests

* rename flags

* code refactor

* fix typo

* update docs

* update test

* Update x/auth/client/cli/tx_multisign.go

* use named return values and explicit return

* Update x/auth/client/cli/tx_multisign.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update x/auth/client/cli/tx_multisign.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Jonathan Gimeno <jonathan@tendermint.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-02-24 19:56:10 +00:00
Marko 2c18d8a28b
add tm version to makefile (#8689) 2021-02-24 19:43:12 +00:00
MD Aleem 897f20b1d1
fix REST endpoints in migration docs (#8648)
* fix endpoints

* update docs

* fix routes

* update docs

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
2021-02-24 15:03:27 +00:00
Amaury 2539acd6f7
simapp InitChainer: use json instead of tmjson (#7523)
* simapp InitChainer: use json instead of tmjson

* First run for test

* Revert export_test

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-24 14:49:34 +00:00
Robert Zaremba 7969135abc
rework unsafe string -> bytes conversion #8674 (#8684)
Changing the unsafe string -> bytes conversion to fix
a security concern.

Closes: #8670

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-24 12:47:32 +00:00