From c7872091cc4d04170e6eacdd63a3b26a44615aae Mon Sep 17 00:00:00 2001 From: catShaark Date: Sun, 12 Jun 2022 03:50:03 +0700 Subject: [PATCH 1/3] increase maxApproxRootIterations to 300 --- types/decimal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/decimal.go b/types/decimal.go index 795f4e693139..ca9dc3ca5730 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -34,7 +34,7 @@ const ( maxDecBitLen = MaxBitLen + decimalTruncateBits // max number of iterations in ApproxRoot function - maxApproxRootIterations = 100 + maxApproxRootIterations = 300 ) var ( From b8040fc3a185ab610e2728a0e3d0ebb0d073ea1a Mon Sep 17 00:00:00 2001 From: romelukaku Date: Thu, 16 Jun 2022 10:35:24 +0700 Subject: [PATCH 2/3] add one test case to TestApproxRoot --- types/decimal_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/decimal_test.go b/types/decimal_test.go index a6939c5f7a05..9416b94938aa 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -433,11 +433,12 @@ func (s *decimalTestSuite) TestApproxRoot() { {sdk.SmallestDec(), 2, sdk.NewDecWithPrec(1, 9)}, // 1e-18 ^ (0.5) => 1e-9 {sdk.SmallestDec(), 3, sdk.MustNewDecFromStr("0.000000999999999997")}, // 1e-18 ^ (1/3) => 1e-6 {sdk.NewDecWithPrec(1, 8), 3, sdk.MustNewDecFromStr("0.002154434690031900")}, // 1e-8 ^ (1/3) ≈ 0.00215443469 + {sdk.MustNewDecFromStr("9000002314687921634000000000000000000021394871242000000000000000"), 2, sdk.MustNewDecFromStr("94868342004527103646332858502867.899477053226766107")}, } // In the case of 1e-8 ^ (1/3), the result repeats every 5 iterations starting from iteration 24 // (i.e. 24, 29, 34, ... give the same result) and never converges enough. The maximum number of - // iterations (100) causes the result at iteration 100 to be returned, regardless of convergence. + // iterations (300) causes the result at iteration 300 to be returned, regardless of convergence. for i, tc := range testCases { res, err := tc.input.ApproxRoot(tc.root) From 7f7fc9707a55f4aa376fa183e06ec526c71156e9 Mon Sep 17 00:00:00 2001 From: romelukaku Date: Thu, 16 Jun 2022 10:42:30 +0700 Subject: [PATCH 3/3] add Changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d47d707614..50197b2ac187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. * (x/authz) [#12184](https://github.com/cosmos/cosmos-sdk/pull/12184) Fix MsgExec not verifying the validity of nested messages. * (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs. +* (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300 ## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23