Commit Graph

27 Commits

Author SHA1 Message Date
Emmanuel T Odeke 6344d626db
types/Coin: compile and reuse Regexps to reduce massive RAM+CPU burn (#7989)
* types/Coin: compile and reuse Regexps to reduce massive RAM+CPU burn

Fixes a resource (CPU+RAM) burn from recompiling Regexps which would
consume 1.2+MiB of RAM and 1.1ms per ParseCoin invocation, which means
that 1,000 invocations would consume 1.2GiB of RAM and >1second.

With the change, ParseCoin now takes 3.2us down from 1.1ms, with
dramatic results:

name         old time/op    new time/op    delta
ParseCoin-8    1.04ms ± 4%    0.00ms ± 1%  -99.69%  (p=0.000 n=9+10)

name         old alloc/op   new alloc/op   delta
ParseCoin-8    1.20MB ± 0%    0.00MB ± 0%  -99.94%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
ParseCoin-8     17.8k ± 0%      0.0k ± 0%  -99.89%  (p=0.000 n=10+10)

Fixes #7986.

* replace the CoinDenomRegex variable with SetCoinDenomRegex() (#7998)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-11-20 19:37:45 +00:00
billy rennekamp 3e6089dc0e
R4R: Add custom validation for denom (#6755)
Allow ValidateDenom to be customized per application.

closes: #6744
2020-10-06 18:06:41 +01:00
dauTT 30f9862b4b
Remove zero coins from ParseCoins and ParseDecCoins (#7348)
* Remove zero coins from ParseCoins and ParseDecCoins

* Implement requested changes

* Update types/coin_test.go

* Revert

* Align the behaviour of NewCoins and ParseCoins (respectively NewDecCoins and ParseDecCoins)

* Amend comments

* Update types/dec_coin.go

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
2020-09-25 08:31:31 +00:00
Federico Kunze 1b08e1032c
types: update coin regex (#7027)
* types: update coin regex

* more tests

* fix test case

* increase coverage

* changelog

* fix tests

* support unicode letters and numbers

* remove ToUpper

* Update types/coin.go

Co-authored-by: Aaron Craelius <aaron@regen.network>

* Validate function

* fix ICS20 test

* table tests and revert unicodes

* add test case

* add test cases and comment

Co-authored-by: Aaron Craelius <aaron@regen.network>
2020-08-14 09:09:53 +00:00
Ira Miller 282afcdb12
Fix for 6786 removeZeroCoins mutates original slice (#6811)
* added test cases to show errors identified in 6786

* mods to fix remove zero coin mutation in slice

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-07-28 10:17:58 +00:00
Marko bef3689245
linter: enable nolintlint (#6162)
* nolintlint enable

* remove space

* fix tests

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-05-08 08:46:12 +00:00
Alexander Bezobchuk 26d6e49d6a
Merge PR #5491: Protobuf Introduction + Types 2020-01-24 10:32:00 -05:00
Ferenc Fabian 066dd1114f Merge PR #5449: Add New constructor for the DecCoin 2020-01-03 15:44:53 -05:00
Federico Kunze fb0a2c46d3
fix DecCoins constructor (#5410)
* fix decCoins

* minor changes for standardization

* changelog

* add test cases
2019-12-16 19:10:18 -03:00
Alexander Bezobchuk 9f03b57fe3
Merge PR #5359: Params Validation 2019-12-10 11:48:57 -05:00
Xuefeng Zhu 3428291a61 Merge PR #5160: Simply Dec and Int sign check
* Simply Dec and Int sign check

* address comment
2019-10-14 16:05:42 -04:00
Marko 3a4f1fc4d4 Merge PR #4881: Linting Galore 2019-08-19 12:06:27 -04:00
Aleksandr Bezobchuk de720660db
Remove panic on zero input during MulDecTruncate 2019-04-10 21:44:24 -04:00
Alexander Bezobchuk 576eb51928
Merge PR #4058: Fix DecCoins Bugs 2019-04-05 14:13:22 -04:00
Alexander Bezobchuk dd7de2acaf
Merge PR #3951: Remove ';' delimiting support from ParseDecCoins 2019-03-25 10:38:15 -04:00
Alexander Bezobchuk 5f92fef4b0
Fix TruncateDecimal (#3913) 2019-03-16 16:14:37 -07:00
Alexander Bezobchuk b316c477c1 Merge PR #3836: Fix WithdrawValidatorCommission 2019-03-12 16:10:20 +01:00
Christopher Goes 4c50380181
Merge PR #3750: Outstanding per-validator rewards; correctly handle same-BeginBlock redelegation-double-slash 2019-03-06 19:54:12 +01:00
Alessio Treglia b47032d280 Merge PR #3666: improve denom validation 2019-03-01 12:10:22 -08:00
Jae Kwon 7e08b62f4e Merge PR #3726: Cap(clip) reward to remaining coins in AllocateTokens 2019-02-27 21:38:57 +01:00
frog power 4000 a814e5ce66
Merge PR #3679: Consistent Operators
* Minus->Sub Plus->Add Div->Quo

* pending

* Update PENDING.md

Co-Authored-By: rigelrozanski <rigel.rozanski@gmail.com>

* fix

* typo
2019-02-21 12:35:55 -05:00
frog power 4000 ab9de3a7f1
Merge PR #3680: Convenience ToDec()
* NewDecFromInt -> ToDec

* pending

* Update PENDING.md

Co-Authored-By: rigelrozanski <rigel.rozanski@gmail.com>

* test typo

* typo
2019-02-21 03:05:31 -05:00
Alexander Bezobchuk 26c13b28cd Merge PR #3607: Reconcile DecCoin/s API with Coin/s API 2019-02-15 16:33:23 +01:00
Alexander Bezobchuk 7bc837aa06 Merge PR #3555: Reintroduce Fees OR Semantics 2019-02-07 18:14:54 -08:00
Jack Zampolin af60c75dd3 Merge PR #3352: Reenable simulation tests 2019-01-24 22:01:32 +01:00
Alexander Bezobchuk 36d1736a08 Refactor Gas/Fee Model (#3258) 2019-01-18 08:45:20 -08:00
Christopher Goes 2942f83ff5
Merge PR #3099: F1 fee distribution 2019-01-16 22:38:05 +01:00