From d572c261e894598596bca78154fac13fe0df791b Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Wed, 15 Feb 2023 17:11:34 -0800 Subject: [PATCH 01/12] add rand file to math --- crypto/types/compact_bit_array_test.go | 4 +- math/rand.go | 137 +++++++++++++++++++++++++ simapp/simd/cmd/testnet.go | 3 +- store/internal/proofs/helpers.go | 6 +- testutil/network/network.go | 3 +- x/genutil/client/cli/init.go | 4 +- 6 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 math/rand.go diff --git a/crypto/types/compact_bit_array_test.go b/crypto/types/compact_bit_array_test.go index 57b7b3830c1a..02b758c0d2cb 100644 --- a/crypto/types/compact_bit_array_test.go +++ b/crypto/types/compact_bit_array_test.go @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - cmtrand "github.com/cometbft/cometbft/libs/rand" + sdkmath "cosmossdk.io/math" ) func randCompactBitArray(bits int) (*CompactBitArray, []byte) { numBytes := (bits + 7) / 8 - src := cmtrand.Bytes((bits + 7) / 8) + src := sdkmath.Bytes((bits + 7) / 8) bA := NewCompactBitArray(bits) for i := 0; i < numBytes-1; i++ { diff --git a/math/rand.go b/math/rand.go new file mode 100644 index 000000000000..4cf69dac0814 --- /dev/null +++ b/math/rand.go @@ -0,0 +1,137 @@ +package math + +import ( + crand "crypto/rand" + mrand "math/rand" + "sync" +) + +const ( + strChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" // 62 characters +) + +// Rand is a prng, that is seeded with OS randomness. +// The OS randomness is obtained from crypto/rand, however none of the provided +// methods are suitable for cryptographic usage. +// They all utilize math/rand's prng internally. +// +// All of the methods here are suitable for concurrent use. +// This is achieved by using a mutex lock on all of the provided methods. +type Rand struct { + sync.Mutex + rand *mrand.Rand +} + +var grand *Rand + +func init() { + grand = NewRand() + grand.init() +} + +func NewRand() *Rand { + rand := &Rand{} + rand.init() + return rand +} + +func (r *Rand) init() { + bz := cRandBytes(8) + var seed uint64 + for i := 0; i < 8; i++ { + seed |= uint64(bz[i]) + seed <<= 8 + } + r.reset(int64(seed)) +} + +func (r *Rand) reset(seed int64) { + r.rand = mrand.New(mrand.NewSource(seed)) +} + +//---------------------------------------- +// Global functions + +func Seed(seed int64) { + grand.Seed(seed) +} + +func Str(length int) string { + return grand.Str(length) +} + +func Int63() int64 { + return grand.Int63() +} + +func Bytes(n int) []byte { + return grand.Bytes(n) +} + +//---------------------------------------- +// Rand methods + +func (r *Rand) Seed(seed int64) { + r.Lock() + r.reset(seed) + r.Unlock() +} + +// Str constructs a random alphanumeric string of given length. +func (r *Rand) Str(length int) string { + if length <= 0 { + return "" + } + + chars := []byte{} +MAIN_LOOP: + for { + val := r.Int63() + for i := 0; i < 10; i++ { + v := int(val & 0x3f) // rightmost 6 bits + if v >= 62 { // only 62 characters in strChars + val >>= 6 + continue + } else { + chars = append(chars, strChars[v]) + if len(chars) == length { + break MAIN_LOOP + } + val >>= 6 + } + } + } + + return string(chars) +} + +func (r *Rand) Int63() int64 { + r.Lock() + i63 := r.rand.Int63() + r.Unlock() + return i63 +} + +// Bytes returns n random bytes generated from the internal +// prng. +func (r *Rand) Bytes(n int) []byte { + // cRandBytes isn't guaranteed to be fast so instead + // use random bytes generated from the internal PRNG + bs := make([]byte, n) + for i := 0; i < len(bs); i++ { + bs[i] = byte(r.Int() & 0xFF) + } + return bs +} + +// NOTE: This relies on the os's random number generator. +// For real security, we should salt that with some seed. +// See github.com/cometbft/cometbft/crypto for a more secure reader. +func cRandBytes(numBytes int) []byte { + b := make([]byte, numBytes) + _, err := crand.Read(b) + if err != nil { + panic(err) + } + return b +} diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 9dd0c00374a1..2f7fd8ef5e95 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -10,7 +10,6 @@ import ( "path/filepath" cmtconfig "github.com/cometbft/cometbft/config" - cmtrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/types" cmttime "github.com/cometbft/cometbft/types/time" "github.com/spf13/cobra" @@ -209,7 +208,7 @@ func initTestnetFiles( args initArgs, ) error { if args.chainID == "" { - args.chainID = "chain-" + cmtrand.Str(6) + args.chainID = "chain-" + math.Str(6) } nodeIDs := make([]string, args.numValidators) valPubKeys := make([]cryptotypes.PubKey, args.numValidators) diff --git a/store/internal/proofs/helpers.go b/store/internal/proofs/helpers.go index 0fd0836155b0..088b6d2eea61 100644 --- a/store/internal/proofs/helpers.go +++ b/store/internal/proofs/helpers.go @@ -3,7 +3,7 @@ package proofs import ( "sort" - "github.com/cometbft/cometbft/libs/rand" + "cosmossdk.io/math" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "golang.org/x/exp/maps" @@ -66,7 +66,7 @@ func GetKey(allkeys []string, loc Where) string { return allkeys[len(allkeys)-1] } // select a random index between 1 and allkeys-2 - idx := rand.NewRand().Int()%(len(allkeys)-2) + 1 + idx := math.NewRand().Int()%(len(allkeys)-2) + 1 return allkeys[idx] } @@ -94,7 +94,7 @@ func BuildMap(size int) map[string][]byte { data := make(map[string][]byte) // insert lots of info and store the bytes for i := 0; i < size; i++ { - key := rand.Str(20) + key := math.Str(20) data[key] = toValue(key) } return data diff --git a/testutil/network/network.go b/testutil/network/network.go index 8b7f9703aa07..dd42c7efb7db 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -19,7 +19,6 @@ import ( "cosmossdk.io/log" sdkmath "cosmossdk.io/math" cmtlog "github.com/cometbft/cometbft/libs/log" - cmtrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/node" cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" @@ -143,7 +142,7 @@ func DefaultConfig(factory TestFixtureFactory) Config { AppConstructor: fixture.AppConstructor, GenesisState: fixture.GenesisState, TimeoutCommit: 2 * time.Second, - ChainID: "chain-" + cmtrand.Str(6), + ChainID: "chain-" + sdkmath.Str(6), NumValidators: 4, BondDenom: sdk.DefaultBondDenom, MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 408fd6e396d9..57a76ac70533 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -7,9 +7,9 @@ import ( "os" "path/filepath" + "cosmossdk.io/math" cfg "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/libs/cli" - cmtrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/types" "github.com/cosmos/go-bip39" "github.com/pkg/errors" @@ -86,7 +86,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { case clientCtx.ChainID != "": chainID = clientCtx.ChainID default: - chainID = fmt.Sprintf("test-chain-%v", cmtrand.Str(6)) + chainID = fmt.Sprintf("test-chain-%v", math.Str(6)) } // Get bip39 mnemonic From 63dcd656cf3d5ccbd9715db626cca58f68870e31 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Wed, 15 Feb 2023 17:16:17 -0800 Subject: [PATCH 02/12] remove from store --- store/cachekv/store_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index 8d4b7f9910f7..bc3644eff30c 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - cmtrand "github.com/cometbft/cometbft/libs/rand" + "cosmossdk.io/math" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" @@ -461,7 +461,7 @@ const ( ) func randInt(n int) int { - return cmtrand.NewRand().Int() % n + return math.NewRand().Int() % n } // useful for replaying a error case if we find one From db638a46579bed0e499671ed7cecd1a5ee9c324f Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 16 Feb 2023 09:06:08 -0800 Subject: [PATCH 03/12] move rand.go to unsafe package --- math/{ => unsafe}/rand.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename math/{ => unsafe}/rand.go (99%) diff --git a/math/rand.go b/math/unsafe/rand.go similarity index 99% rename from math/rand.go rename to math/unsafe/rand.go index 4cf69dac0814..c34fc193d07e 100644 --- a/math/rand.go +++ b/math/unsafe/rand.go @@ -1,4 +1,4 @@ -package math +package unsafe import ( crand "crypto/rand" From dcb3a6b22c27bc856a951af301e6bf47f179454a Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 16 Feb 2023 09:14:38 -0800 Subject: [PATCH 04/12] fix build --- math/unsafe/rand.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/math/unsafe/rand.go b/math/unsafe/rand.go index c34fc193d07e..e7fb3c44b3c2 100644 --- a/math/unsafe/rand.go +++ b/math/unsafe/rand.go @@ -64,6 +64,10 @@ func Int63() int64 { return grand.Int63() } +func Int() int { + return grand.Int() +} + func Bytes(n int) []byte { return grand.Bytes(n) } @@ -112,6 +116,13 @@ func (r *Rand) Int63() int64 { return i63 } +func (r *Rand) Int() int { + r.Lock() + i := r.rand.Int() + r.Unlock() + return i +} + // Bytes returns n random bytes generated from the internal // prng. func (r *Rand) Bytes(n int) []byte { From 6cb929c072d09ebcc2999931af623fafe9941736 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 16 Feb 2023 09:20:49 -0800 Subject: [PATCH 05/12] fix imports --- crypto/types/compact_bit_array_test.go | 4 ++-- simapp/simd/cmd/testnet.go | 6 +++--- store/internal/proofs/helpers.go | 3 ++- testutil/network/network.go | 3 ++- x/genutil/client/cli/init.go | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crypto/types/compact_bit_array_test.go b/crypto/types/compact_bit_array_test.go index 02b758c0d2cb..4831e8e681ea 100644 --- a/crypto/types/compact_bit_array_test.go +++ b/crypto/types/compact_bit_array_test.go @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdkmath "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" ) func randCompactBitArray(bits int) (*CompactBitArray, []byte) { numBytes := (bits + 7) / 8 - src := sdkmath.Bytes((bits + 7) / 8) + src := unsafe.Bytes((bits + 7) / 8) bA := NewCompactBitArray(bits) for i := 0; i < numBytes-1; i++ { diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 2f7fd8ef5e95..3e5fa258f81d 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -9,14 +9,14 @@ import ( "os" "path/filepath" + "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" cmtconfig "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/types" cmttime "github.com/cometbft/cometbft/types/time" "github.com/spf13/cobra" "github.com/spf13/pflag" - "cosmossdk.io/math" - "cosmossdk.io/simapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -208,7 +208,7 @@ func initTestnetFiles( args initArgs, ) error { if args.chainID == "" { - args.chainID = "chain-" + math.Str(6) + args.chainID = "chain-" + unsafe.Str(6) } nodeIDs := make([]string, args.numValidators) valPubKeys := make([]cryptotypes.PubKey, args.numValidators) diff --git a/store/internal/proofs/helpers.go b/store/internal/proofs/helpers.go index 088b6d2eea61..78a8b7b1b4f8 100644 --- a/store/internal/proofs/helpers.go +++ b/store/internal/proofs/helpers.go @@ -4,6 +4,7 @@ import ( "sort" "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "golang.org/x/exp/maps" @@ -94,7 +95,7 @@ func BuildMap(size int) map[string][]byte { data := make(map[string][]byte) // insert lots of info and store the bytes for i := 0; i < size; i++ { - key := math.Str(20) + key := unsafe.Str(20) data[key] = toValue(key) } return data diff --git a/testutil/network/network.go b/testutil/network/network.go index dd42c7efb7db..088aa950d132 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -18,6 +18,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" cmtlog "github.com/cometbft/cometbft/libs/log" "github.com/cometbft/cometbft/node" cmtclient "github.com/cometbft/cometbft/rpc/client" @@ -142,7 +143,7 @@ func DefaultConfig(factory TestFixtureFactory) Config { AppConstructor: fixture.AppConstructor, GenesisState: fixture.GenesisState, TimeoutCommit: 2 * time.Second, - ChainID: "chain-" + sdkmath.Str(6), + ChainID: "chain-" + unsafe.Str(6), NumValidators: 4, BondDenom: sdk.DefaultBondDenom, MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 57a76ac70533..49afddc82d7c 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" - "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" cfg "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/libs/cli" "github.com/cometbft/cometbft/types" @@ -86,7 +86,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { case clientCtx.ChainID != "": chainID = clientCtx.ChainID default: - chainID = fmt.Sprintf("test-chain-%v", math.Str(6)) + chainID = fmt.Sprintf("test-chain-%v", unsafe.Str(6)) } // Get bip39 mnemonic From 959ce49135e4b6f16ba099c4d29afa15abeee52d Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 16 Feb 2023 09:21:21 -0800 Subject: [PATCH 06/12] fix imports v2 --- store/cachekv/store_test.go | 4 ++-- store/internal/proofs/helpers.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index bc3644eff30c..3694726a7935 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" @@ -461,7 +461,7 @@ const ( ) func randInt(n int) int { - return math.NewRand().Int() % n + return unsafe.NewRand().Int() % n } // useful for replaying a error case if we find one diff --git a/store/internal/proofs/helpers.go b/store/internal/proofs/helpers.go index 78a8b7b1b4f8..cad3acd5dc70 100644 --- a/store/internal/proofs/helpers.go +++ b/store/internal/proofs/helpers.go @@ -3,7 +3,6 @@ package proofs import ( "sort" - "cosmossdk.io/math" "cosmossdk.io/math/unsafe" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "golang.org/x/exp/maps" @@ -67,7 +66,7 @@ func GetKey(allkeys []string, loc Where) string { return allkeys[len(allkeys)-1] } // select a random index between 1 and allkeys-2 - idx := math.NewRand().Int()%(len(allkeys)-2) + 1 + idx := unsafe.NewRand().Int()%(len(allkeys)-2) + 1 return allkeys[idx] } From 1b30bbbc76f4551e2bb3499f8ca9c64465236974 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 16 Feb 2023 10:50:43 -0800 Subject: [PATCH 07/12] update go mod --- go.mod | 2 +- go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 2 ++ store/go.mod | 2 +- store/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 6d49eb1e9239..bc10a9c28bae 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/errors v1.0.0-beta.7 cosmossdk.io/log v0.0.0-00010101000000-000000000000 - cosmossdk.io/math v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 cosmossdk.io/x/tx v0.2.0 github.com/99designs/keyring v1.2.1 diff --git a/go.sum b/go.sum index 83371f21cedb..eebd15c99a7c 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= diff --git a/simapp/go.mod b/simapp/go.mod index 73acd3f18c16..501e5a1bd924 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/core v0.5.1 cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/log v0.0.0 - cosmossdk.io/math v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 cosmossdk.io/tools/confix v0.0.0-20230120150717-4f6f6c00021f cosmossdk.io/tools/rosetta v0.2.0 diff --git a/simapp/go.sum b/simapp/go.sum index b46cb77224b7..ed831fc18f40 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -60,6 +60,8 @@ cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= diff --git a/store/go.mod b/store/go.mod index 36e5a363cee7..627e1e2ac41e 100644 --- a/store/go.mod +++ b/store/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( cosmossdk.io/errors v1.0.0-beta.7 cosmossdk.io/log v0.0.0-00010101000000-000000000000 - cosmossdk.io/math v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 github.com/armon/go-metrics v0.4.1 github.com/cometbft/cometbft v0.0.0-20230203130311-387422ac220d github.com/confio/ics23/go v0.9.0 diff --git a/store/go.sum b/store/go.sum index 608577c46a9f..64b691ba234e 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= From de24a4fb1cd134add802abca54e0019ecca99737 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Fri, 17 Feb 2023 16:48:52 +0100 Subject: [PATCH 08/12] fix cosmovisor build --- tools/cosmovisor/go.mod | 2 +- tools/cosmovisor/go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index cf7771ef0772..47e3123b02cf 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -22,7 +22,7 @@ require ( cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/math v1.0.0-beta.6 // indirect + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 // indirect cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index be018dd6ba70..ecd960db4b4c 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -200,6 +200,8 @@ cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= From bf2f20e3772fa34dffa8f8486b9b1837f19b3e4c Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Sat, 18 Feb 2023 02:40:09 +0100 Subject: [PATCH 09/12] rosetta build --- tools/rosetta/go.mod | 2 +- tools/rosetta/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/rosetta/go.mod b/tools/rosetta/go.mod index a746310eb3b4..bd7bb5b73c57 100644 --- a/tools/rosetta/go.mod +++ b/tools/rosetta/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( cosmossdk.io/log v0.0.0 - cosmossdk.io/math v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 github.com/coinbase/rosetta-sdk-go/types v1.0.0 github.com/cometbft/cometbft v0.0.0-20230203130311-387422ac220d github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230205135133-41a3dfeced29 diff --git a/tools/rosetta/go.sum b/tools/rosetta/go.sum index 47231ccb51e4..8d6161c0afaa 100644 --- a/tools/rosetta/go.sum +++ b/tools/rosetta/go.sum @@ -45,8 +45,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= From 968a0968c626822cb39ab5de601448579322820a Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Sat, 18 Feb 2023 02:52:00 +0100 Subject: [PATCH 10/12] tests build --- tests/go.mod | 2 +- tests/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 020fdd2c6714..b32ae990bc58 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.3.0 cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/log v0.0.0 - cosmossdk.io/math v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 cosmossdk.io/simapp v0.0.0-00010101000000-000000000000 cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 cosmossdk.io/x/evidence v0.1.0 diff --git a/tests/go.sum b/tests/go.sum index 0df82dde1a1b..aa263db91594 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -200,8 +200,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= From a83f3a58ef18bba0488f1924344af5f7f377d233 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Sat, 18 Feb 2023 19:12:24 +0100 Subject: [PATCH 11/12] build and changelog --- math/CHANGELOG.md | 3 ++- tools/confix/go.mod | 2 +- tools/confix/go.sum | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/math/CHANGELOG.md b/math/CHANGELOG.md index f153b00a0950..3efa0e274b59 100644 --- a/math/CHANGELOG.md +++ b/math/CHANGELOG.md @@ -34,4 +34,5 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#14010](https://github.com/cosmos/cosmos-sdk/pull/14010) Optimize FormatInt to not do plain string concentation when formatting thousands and instead build it more efficiently. * [#13381](https://github.com/cosmos/cosmos-sdk/pull/13381) Add uint `IsNil` method. * [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package, call it `LegacyDec`. -* [#14166](https://github.com/cosmos/cosmos-sdk/pull/14166) Add generics versions of Max and Min, catering to all numeric types and allow for variadic calls, replacing the prior typed and strenous code +* [#14166](https://github.com/cosmos/cosmos-sdk/pull/14166) Add generics versions of Max and Min, catering to all numeric types and allow for variadic calls, replacing the prior typed and strenuous code +* [#15043](https://github.com/cosmos/cosmos-sdk/pull/15043) Add rand functions for testing purposes diff --git a/tools/confix/go.mod b/tools/confix/go.mod index e45e653152ea..1f822cafa0f7 100644 --- a/tools/confix/go.mod +++ b/tools/confix/go.mod @@ -19,7 +19,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect cosmossdk.io/log v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/math v1.0.0-beta.6 // indirect + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 // indirect cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 // indirect cosmossdk.io/x/tx v0.2.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect diff --git a/tools/confix/go.sum b/tools/confix/go.sum index 11e52e879568..603437632cef 100644 --- a/tools/confix/go.sum +++ b/tools/confix/go.sum @@ -45,8 +45,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg= From 6457d49c3aac6cb9d1fd5e9d5d06013b50bafe10 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Sat, 18 Feb 2023 19:19:05 +0100 Subject: [PATCH 12/12] build for the 100th time --- tools/hubl/go.mod | 2 +- tools/hubl/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index a0fbedd44931..44f8f1011683 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -21,7 +21,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect cosmossdk.io/log v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/math v1.0.0-beta.6 // indirect + cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 // indirect cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum index a588e375adfc..af5fb65ba019 100644 --- a/tools/hubl/go.sum +++ b/tools/hubl/go.sum @@ -47,8 +47,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE= -cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= +cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE= cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7/go.mod h1:1XOtuYs7jsfQkn7G3VQXB6I+2tHXKHZw2U/AafNbnlk= cosmossdk.io/x/tx v0.2.0 h1:53f5TIXhpPYJGMm47SUslcV2i8JNBEN3eE08BmxE/Zg=