From 089280fb42a739c15c69256b609afb898438cb97 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 29 Aug 2023 12:06:14 -0700 Subject: [PATCH 01/50] updates --- store/multistore/store.go | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 store/multistore/store.go diff --git a/store/multistore/store.go b/store/multistore/store.go new file mode 100644 index 000000000000..fc2754ef3790 --- /dev/null +++ b/store/multistore/store.go @@ -0,0 +1,6 @@ +package multistore + +// TODO: Move this to Core package. +type MultiStore interface{} + +type Store struct{} From 6f868c3fa8420e4eaf98ef05a708526a7ee8f283 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 29 Aug 2023 16:47:55 -0700 Subject: [PATCH 02/50] updates --- store/multistore/store.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index fc2754ef3790..cbd91873e646 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -1,6 +1,17 @@ package multistore +import ( + "cosmossdk.io/store/v2" + "cosmossdk.io/store/v2/commitment" +) + // TODO: Move this to Core package. -type MultiStore interface{} +type MultiStore interface { + WorkingHash() []byte + Commit() error +} -type Store struct{} +type Store struct { + ss store.VersionedDatabase + sc map[string]*commitment.Database +} From 54dd27aa47f6291828c172bd2b98bcf835f762b3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 29 Aug 2023 16:50:36 -0700 Subject: [PATCH 03/50] updates --- store/multistore/store.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index cbd91873e646..dde867c5d200 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -3,12 +3,18 @@ package multistore import ( "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" + ics23 "github.com/cosmos/ics23/go" ) -// TODO: Move this to Core package. +// MultiStore defines an abstraction layer containing a State Storage (SS) engine +// and one or more State Commitment (SC) engines. +// +// TODO: Move this type to the Core package. type MultiStore interface { + GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) + LoadVersion(version uint64) error WorkingHash() []byte - Commit() error + Commit() ([]byte, error) } type Store struct { From 466d06ff1d50c921dee6fccc9542f27569a5d0cb Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 29 Aug 2023 16:54:20 -0700 Subject: [PATCH 04/50] updates --- store/multistore/store.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index dde867c5d200..724c9610dc85 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -1,6 +1,8 @@ package multistore import ( + "io" + "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" ics23 "github.com/cosmos/ics23/go" @@ -11,12 +13,17 @@ import ( // // TODO: Move this type to the Core package. type MultiStore interface { + GetSCStore(storeKey string) *commitment.Database GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error WorkingHash() []byte Commit() ([]byte, error) + + io.Closer } +var _ MultiStore = &Store{} + type Store struct { ss store.VersionedDatabase sc map[string]*commitment.Database From ee79932b5fd86079eb08b269f7f8ff04f20b7d6b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 29 Aug 2023 17:02:06 -0700 Subject: [PATCH 05/50] updates --- store/multistore/store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index 724c9610dc85..b0f929e9d68d 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -18,6 +18,10 @@ type MultiStore interface { LoadVersion(version uint64) error WorkingHash() []byte Commit() ([]byte, error) + // TODO: + // - Tracing + // - Pruning + // - Queries io.Closer } From 92e7767dc1761a7d8812b2ff794c6d50bc59a2c1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 2 Sep 2023 21:04:07 -0700 Subject: [PATCH 06/50] updates --- store/multistore/store.go | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index b0f929e9d68d..ccc4cec4abf6 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -1,6 +1,8 @@ package multistore import ( + "errors" + "fmt" "io" "cosmossdk.io/store/v2" @@ -14,6 +16,7 @@ import ( // TODO: Move this type to the Core package. type MultiStore interface { GetSCStore(storeKey string) *commitment.Database + MountSCStore(storeKey string, sc *commitment.Database) error GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error WorkingHash() []byte @@ -29,6 +32,42 @@ type MultiStore interface { var _ MultiStore = &Store{} type Store struct { - ss store.VersionedDatabase - sc map[string]*commitment.Database + ss store.VersionedDatabase + sc map[string]*commitment.Database + version uint64 +} + +func New(ss store.VersionedDatabase) (MultiStore, error) { + latestVersion, err := ss.GetLatestVersion() + if err != nil { + return nil, fmt.Errorf("failed to get latest version: %w", err) + } + + return &Store{ + ss: ss, + sc: make(map[string]*commitment.Database), + version: latestVersion, + }, nil +} + +func (s *Store) Close() (err error) { + err = errors.Join(err, s.ss.Close()) + for _, sc := range s.sc { + err = errors.Join(err, sc.Close()) + } + + s.ss = nil + s.sc = nil + s.version = 0 + + return err +} + +func (ms *Store) MountSCStore(storeKey string, sc *commitment.Database) error { + if _, ok := ms.sc[storeKey]; ok { + return fmt.Errorf("store with key %s already mounted", storeKey) + } + + ms.sc[storeKey] = sc + return nil } From 57b675feae1f14a542c23c30614eab6782dbf1e1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 2 Sep 2023 21:05:06 -0700 Subject: [PATCH 07/50] updates --- store/multistore/store.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index ccc4cec4abf6..eab248ae680b 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -21,9 +21,10 @@ type MultiStore interface { LoadVersion(version uint64) error WorkingHash() []byte Commit() ([]byte, error) + // TODO: // - Tracing - // - Pruning + // - Branching // - Queries io.Closer @@ -63,11 +64,20 @@ func (s *Store) Close() (err error) { return err } -func (ms *Store) MountSCStore(storeKey string, sc *commitment.Database) error { - if _, ok := ms.sc[storeKey]; ok { +func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { + if _, ok := s.sc[storeKey]; ok { return fmt.Errorf("store with key %s already mounted", storeKey) } - ms.sc[storeKey] = sc + s.sc[storeKey] = sc return nil } + +func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) { + sc, ok := s.sc[storeKey] + if !ok { + return nil, fmt.Errorf("store with key %s not mounted", storeKey) + } + + return sc.GetProof(version, key) +} From 63e167b6a7d7226419bf5f5d59ef45a37c065ffb Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 2 Sep 2023 21:07:45 -0700 Subject: [PATCH 08/50] updates --- store/multistore/store.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index eab248ae680b..63ddb8a82c0b 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -19,6 +19,7 @@ type MultiStore interface { MountSCStore(storeKey string, sc *commitment.Database) error GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error + GetLatestVersion() (uint64, error) WorkingHash() []byte Commit() ([]byte, error) @@ -66,17 +67,28 @@ func (s *Store) Close() (err error) { func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { if _, ok := s.sc[storeKey]; ok { - return fmt.Errorf("store with key %s already mounted", storeKey) + return fmt.Errorf("SC store with key %s already mounted", storeKey) } s.sc[storeKey] = sc return nil } +func (s *Store) GetLatestVersion() (uint64, error) { + for _, sc := range s.sc { + v := sc.GetLatestVersion() + if v != s.version { + return 0, fmt.Errorf("latest version mismatch for SC store; %d != %d", v, s.version) + } + } + + return s.version, nil +} + func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) { sc, ok := s.sc[storeKey] if !ok { - return nil, fmt.Errorf("store with key %s not mounted", storeKey) + return nil, fmt.Errorf("SC store with key %s not mounted", storeKey) } return sc.GetProof(version, key) From f8e95433f841ad3a430082d9af5dae1bd7db9f65 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 2 Sep 2023 21:08:54 -0700 Subject: [PATCH 09/50] updates --- store/multistore/store.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index 63ddb8a82c0b..abc4cb4e8af4 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -93,3 +93,19 @@ func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.Co return sc.GetProof(version, key) } + +func (s *Store) GetSCStore(storeKey string) *commitment.Database { + panic("not implemented!") +} + +func (s *Store) LoadVersion(version uint64) error { + panic("not implemented!") +} + +func (s *Store) WorkingHash() []byte { + panic("not implemented!") +} + +func (s *Store) Commit() ([]byte, error) { + panic("not implemented!") +} From 61259cd1bec3bc03998dccc3863e92e392d85cbc Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Sep 2023 10:26:15 -0700 Subject: [PATCH 10/50] updates --- store/go.mod | 8 +- store/go.sum | 204 ++------------------------------------ store/multistore/store.go | 105 +++++++++++++++----- 3 files changed, 91 insertions(+), 226 deletions(-) diff --git a/store/go.mod b/store/go.mod index 15c9242d2952..3e4a169d6e77 100644 --- a/store/go.mod +++ b/store/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/log v1.2.0 + github.com/cockroachdb/errors v1.11.1 github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c github.com/cometbft/cometbft v0.38.0-rc3 github.com/cosmos/cosmos-db v1.0.0 @@ -21,15 +22,14 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/errors v1.8.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect - github.com/cockroachdb/redact v1.0.8 // indirect - github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emicklei/dot v1.4.2 // indirect + github.com/getsentry/sentry-go v0.18.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect diff --git a/store/go.sum b/store/go.sum index e96709781f13..55fa0389d398 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1,52 +1,30 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= -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-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= -github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM= -github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= -github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c h1:aDetJlMe4qJxWAwu+/bzTs2/b1EW9ecVyawpRD7N/tE= github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c/go.mod h1:EDjiaAXc0FXiRmxDzcu1wIEJ093ohHMUWxrI6iku0XA= -github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw= -github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/cometbft/cometbft v0.38.0-rc3 h1:Ly3eVPWoFu0y68PmZwLljucPdEBtfigZtqm+OV1W6dE= github.com/cometbft/cometbft v0.38.0-rc3/go.mod h1:5Jz0Z8YsHSf0ZaAqGvi/ifioSdVFPtEGrm8Y9T/993k= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= @@ -56,59 +34,29 @@ github.com/cosmos/iavl v1.0.0-beta.2 h1:XOsIM80Yyml/KifCXEYOy9tWCXwMAbLa91n6pReW github.com/cosmos/iavl v1.0.0-beta.2/go.mod h1:EA97dJ07TBktRlG/iGzK6g1eCXNj1q3MGoFYkVzrwHE= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= +github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -121,116 +69,61 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= -github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= -github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= -github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= github.com/linxGnu/grocksdb v1.8.0/go.mod h1:09CeBborffXhXdNpEcOeZrLKEnRtrZFEpFdPNI9Zjjg= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= -github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:FatpGJD2jmJfhZiFDElaC0QhZUDQnxUeAwTGkfAHN3I= github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= @@ -245,99 +138,45 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -357,14 +196,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -374,18 +205,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 h1:lv6/DhyiFFGsmzxbsUUTOkN29II+zeWHxvT8Lpdxsv0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -399,23 +220,16 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= diff --git a/store/multistore/store.go b/store/multistore/store.go index abc4cb4e8af4..462f1f77f82b 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -1,12 +1,14 @@ package multistore import ( - "errors" "fmt" "io" + "sort" + v1types "cosmossdk.io/store/types" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" + "github.com/cockroachdb/errors" ics23 "github.com/cosmos/ics23/go" ) @@ -33,60 +35,86 @@ type MultiStore interface { var _ MultiStore = &Store{} +// TODO: +// - Commit +// - LoadVersion + type Store struct { - ss store.VersionedDatabase - sc map[string]*commitment.Database - version uint64 + // ss reflects the state storage backend + ss store.VersionedDatabase + + // scStores reflect a mapping of store key to state commitment backend (i.e. a backend per module) + scStores map[string]*commitment.Database + + // removalMap reflects module stores marked for removal + removalMap map[string]struct{} + + // lastCommitInfo reflects the last version/hash that has been committed + lastCommitInfo *v1types.CommitInfo } func New(ss store.VersionedDatabase) (MultiStore, error) { - latestVersion, err := ss.GetLatestVersion() - if err != nil { - return nil, fmt.Errorf("failed to get latest version: %w", err) - } - return &Store{ - ss: ss, - sc: make(map[string]*commitment.Database), - version: latestVersion, + ss: ss, + scStores: make(map[string]*commitment.Database), + removalMap: make(map[string]struct{}), }, nil } func (s *Store) Close() (err error) { err = errors.Join(err, s.ss.Close()) - for _, sc := range s.sc { + for _, sc := range s.scStores { err = errors.Join(err, sc.Close()) } s.ss = nil - s.sc = nil - s.version = 0 + s.scStores = nil + s.lastCommitInfo = nil return err } func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { - if _, ok := s.sc[storeKey]; ok { + if _, ok := s.scStores[storeKey]; ok { return fmt.Errorf("SC store with key %s already mounted", storeKey) } - s.sc[storeKey] = sc + s.scStores[storeKey] = sc return nil } -func (s *Store) GetLatestVersion() (uint64, error) { - for _, sc := range s.sc { - v := sc.GetLatestVersion() - if v != s.version { - return 0, fmt.Errorf("latest version mismatch for SC store; %d != %d", v, s.version) +// LastCommitID returns the latest internal CommitID. If the latest CommitID is +// not set, a new one will be returned with the latest version set only, which +// is based off of the SS view. +func (s *Store) LastCommitID() (v1types.CommitID, error) { + if s.lastCommitInfo == nil { + lv, err := s.ss.GetLatestVersion() + if err != nil { + return v1types.CommitID{}, err } + + return v1types.CommitID{ + Version: int64(lv), + }, nil } - return s.version, nil + return s.lastCommitInfo.CommitID(), nil +} + +// GetLatestVersion returns the latest version based on the latest internal +// CommitInfo. An error is returned if the latest CommitInfo or version cannot +// be retrieved. +func (s *Store) GetLatestVersion() (uint64, error) { + lastCommitID, err := s.LastCommitID() + if err != nil { + return 0, err + } + + return uint64(lastCommitID.Version), nil } func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) { - sc, ok := s.sc[storeKey] + sc, ok := s.scStores[storeKey] if !ok { return nil, fmt.Errorf("SC store with key %s not mounted", storeKey) } @@ -98,12 +126,35 @@ func (s *Store) GetSCStore(storeKey string) *commitment.Database { panic("not implemented!") } -func (s *Store) LoadVersion(version uint64) error { - panic("not implemented!") +func (s *Store) LoadVersion(v uint64) (err error) { + for sk, sc := range s.scStores { + if loadErr := sc.LoadVersion(v); loadErr != nil { + err = errors.Join(err, fmt.Errorf("failed to load version %d for %s: %w", v, sk, loadErr)) + } + } + + return err } func (s *Store) WorkingHash() []byte { - panic("not implemented!") + storeInfos := make([]v1types.StoreInfo, 0, len(s.scStores)) + + for sk, sc := range s.scStores { + if _, ok := s.removalMap[sk]; ok { + storeInfos = append(storeInfos, v1types.StoreInfo{ + Name: sk, + CommitId: v1types.CommitID{ + Hash: sc.WorkingHash(), + }, + }) + } + } + + sort.SliceStable(storeInfos, func(i, j int) bool { + return storeInfos[i].Name < storeInfos[j].Name + }) + + return v1types.CommitInfo{StoreInfos: storeInfos}.Hash() } func (s *Store) Commit() ([]byte, error) { From b1c4d42bf1623d7ed5086c3a6fe732c05fdb088d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Sep 2023 10:47:26 -0700 Subject: [PATCH 11/50] updates --- store/multistore/store.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 462f1f77f82b..b4fec469f5a0 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -5,6 +5,7 @@ import ( "io" "sort" + "cosmossdk.io/log" v1types "cosmossdk.io/store/types" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" @@ -15,7 +16,9 @@ import ( // MultiStore defines an abstraction layer containing a State Storage (SS) engine // and one or more State Commitment (SC) engines. // -// TODO: Move this type to the Core package. +// TODO: +// - Move this type to the Core package. +// - Remove reliance on store v1 types. type MultiStore interface { GetSCStore(storeKey string) *commitment.Database MountSCStore(storeKey string, sc *commitment.Database) error @@ -35,11 +38,9 @@ type MultiStore interface { var _ MultiStore = &Store{} -// TODO: -// - Commit -// - LoadVersion - type Store struct { + logger log.Logger + // ss reflects the state storage backend ss store.VersionedDatabase @@ -53,14 +54,17 @@ type Store struct { lastCommitInfo *v1types.CommitInfo } -func New(ss store.VersionedDatabase) (MultiStore, error) { +func New(logger log.Logger, ss store.VersionedDatabase) (MultiStore, error) { return &Store{ + logger: logger.With("module", "multi_store"), ss: ss, scStores: make(map[string]*commitment.Database), removalMap: make(map[string]struct{}), }, nil } +// Close closes the store and resets all internal fields. Note, Close() is NOT +// idempotent and should only be called once. func (s *Store) Close() (err error) { err = errors.Join(err, s.ss.Close()) for _, sc := range s.scStores { @@ -75,6 +79,7 @@ func (s *Store) Close() (err error) { } func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { + s.logger.Debug("mounting store", "store_key", storeKey) if _, ok := s.scStores[storeKey]; ok { return fmt.Errorf("SC store with key %s already mounted", storeKey) } @@ -127,12 +132,21 @@ func (s *Store) GetSCStore(storeKey string) *commitment.Database { } func (s *Store) LoadVersion(v uint64) (err error) { + return s.loadVersion(v, nil) +} + +func (s *Store) loadVersion(v uint64, upgrades *v1types.StoreUpgrades) (err error) { + s.logger.Debug("loading version", "version", v) + for sk, sc := range s.scStores { if loadErr := sc.LoadVersion(v); loadErr != nil { err = errors.Join(err, fmt.Errorf("failed to load version %d for %s: %w", v, sk, loadErr)) } } + // TODO: Complete this method to handle upgrades. See legacy RMS loadVersion() + // for reference. + return err } From e0d188d28996d899115026500d866ad3f0f80cb3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Sep 2023 10:51:37 -0700 Subject: [PATCH 12/50] updates --- store/multistore/store.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index b4fec469f5a0..8a148c526952 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -24,6 +24,7 @@ type MultiStore interface { MountSCStore(storeKey string, sc *commitment.Database) error GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error + LoadLatestVersion() error GetLatestVersion() (uint64, error) WorkingHash() []byte Commit() ([]byte, error) @@ -98,6 +99,14 @@ func (s *Store) LastCommitID() (v1types.CommitID, error) { return v1types.CommitID{}, err } + // ensure integrity of latest version across all SC stores + for sk, sc := range s.scStores { + scVersion := sc.GetLatestVersion() + if scVersion != lv { + return v1types.CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, lv) + } + } + return v1types.CommitID{ Version: int64(lv), }, nil @@ -131,6 +140,15 @@ func (s *Store) GetSCStore(storeKey string) *commitment.Database { panic("not implemented!") } +func (s *Store) LoadLatestVersion() error { + lv, err := s.GetLatestVersion() + if err != nil { + return err + } + + return s.loadVersion(lv, nil) +} + func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } From 849413c002ea2a69f2656d521f354177732091fc Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Sep 2023 12:01:55 -0700 Subject: [PATCH 13/50] updates --- store/multistore/store.go | 169 +++++++++++++++++++++++++++++++------- 1 file changed, 138 insertions(+), 31 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 8a148c526952..0946275a8625 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -4,6 +4,8 @@ import ( "fmt" "io" "sort" + "strings" + "time" "cosmossdk.io/log" v1types "cosmossdk.io/store/types" @@ -13,34 +15,44 @@ import ( ics23 "github.com/cosmos/ics23/go" ) -// MultiStore defines an abstraction layer containing a State Storage (SS) engine -// and one or more State Commitment (SC) engines. -// -// TODO: -// - Move this type to the Core package. -// - Remove reliance on store v1 types. -type MultiStore interface { - GetSCStore(storeKey string) *commitment.Database - MountSCStore(storeKey string, sc *commitment.Database) error - GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) - LoadVersion(version uint64) error - LoadLatestVersion() error - GetLatestVersion() (uint64, error) - WorkingHash() []byte - Commit() ([]byte, error) - +type ( + // MultiStore defines an abstraction layer containing a State Storage (SS) engine + // and one or more State Commitment (SC) engines. + // // TODO: - // - Tracing - // - Branching - // - Queries + // - Move relevant types to the 'core' package. + // - Remove reliance on store v1 types. + MultiStore interface { + GetSCStore(storeKey string) *commitment.Database + MountSCStore(storeKey string, sc *commitment.Database) error + GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) + LoadVersion(version uint64) error + LoadLatestVersion() error + GetLatestVersion() (uint64, error) + WorkingHash() []byte + Commit() ([]byte, error) + SetCommitHeader(h CommitHeader) + + // TODO: + // - Tracing + // - Branching + // - Queries + + io.Closer + } - io.Closer -} + CommitHeader interface { + GetTime() time.Time + GetHeight() uint64 + } +) var _ MultiStore = &Store{} type Store struct { - logger log.Logger + logger log.Logger + commitHeader CommitHeader + initialVersion uint64 // ss reflects the state storage backend ss store.VersionedDatabase @@ -55,12 +67,13 @@ type Store struct { lastCommitInfo *v1types.CommitInfo } -func New(logger log.Logger, ss store.VersionedDatabase) (MultiStore, error) { +func New(logger log.Logger, initialVersion uint64, ss store.VersionedDatabase) (MultiStore, error) { return &Store{ - logger: logger.With("module", "multi_store"), - ss: ss, - scStores: make(map[string]*commitment.Database), - removalMap: make(map[string]struct{}), + logger: logger.With("module", "multi_store"), + initialVersion: initialVersion, + ss: ss, + scStores: make(map[string]*commitment.Database), + removalMap: make(map[string]struct{}), }, nil } @@ -75,6 +88,8 @@ func (s *Store) Close() (err error) { s.ss = nil s.scStores = nil s.lastCommitInfo = nil + s.commitHeader = nil + s.removalMap = nil return err } @@ -89,9 +104,9 @@ func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { return nil } -// LastCommitID returns the latest internal CommitID. If the latest CommitID is -// not set, a new one will be returned with the latest version set only, which -// is based off of the SS view. +// LastCommitID returns a CommitID based off of the latest internal CommitInfo. +// If an internal CommitInfo is not set, a new one will be returned with only the +// latest version set, which is based off of the SS view. func (s *Store) LastCommitID() (v1types.CommitID, error) { if s.lastCommitInfo == nil { lv, err := s.ss.GetLatestVersion() @@ -189,6 +204,98 @@ func (s *Store) WorkingHash() []byte { return v1types.CommitInfo{StoreInfos: storeInfos}.Hash() } +func (s *Store) SetCommitHeader(h CommitHeader) { + s.commitHeader = h +} + func (s *Store) Commit() ([]byte, error) { - panic("not implemented!") + var previousHeight, version uint64 + if s.lastCommitInfo.GetVersion() == 0 && s.initialVersion > 1 { + // This case means that no commit has been made in the store, we + // start from initialVersion. + version = s.initialVersion + } else { + // This case can means two things: + // + // 1. There was already a previous commit in the store, in which case we + // increment the version from there. + // 2. There was no previous commit, and initial version was not set, in which + // case we start at version 1. + previousHeight = uint64(s.lastCommitInfo.GetVersion()) + version = previousHeight + 1 + } + + if s.commitHeader.GetHeight() != version { + s.logger.Debug("commit header and version mismatch", "header_height", s.commitHeader.GetHeight(), "version", version) + } + + // remove and close all SC stores marked for removal + for sk := range s.removalMap { + if sc, ok := s.scStores[sk]; ok { + if err := sc.Close(); err != nil { + return nil, err + } + + delete(s.scStores, sk) + } + } + + s.removalMap = make(map[string]struct{}) + + // commit writes to SC stores + commitInfo, err := s.commitSC(version) + if err != nil { + return nil, fmt.Errorf("failed to commit SC stores: %w", err) + } + + s.lastCommitInfo = commitInfo + s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() + + // TODO: Commit writes to SS backend asynchronously. + + return s.lastCommitInfo.Hash(), nil +} + +// commitSC commits each SC store individually and returns a CommitInfo +// representing commitment of all the SC stores. Note, commitment is NOT atomic. +// An error is returned if any SC store fails to commit. +func (s *Store) commitSC(version uint64) (*v1types.CommitInfo, error) { + storeInfos := make([]v1types.StoreInfo, 0, len(s.scStores)) + + for sk, sc := range s.scStores { + // TODO: Handle and support SC store last CommitID to handle the case where + // a Commit is interrupted and a SC store could have a version that is ahead: + // + // scLastCommitID := sc.LastCommitID() + + // var commitID v1types.CommitID + // if scLastCommitID.Version >= version { + // scLastCommitID.Version = version + // commitID = scLastCommitID + // } else { + // commitID = store.Commit() + // } + + commitBz, err := sc.Commit() + if err != nil { + return nil, fmt.Errorf("failed to commit SC store %s: %w", sk, err) + } + + storeInfos = append(storeInfos, v1types.StoreInfo{ + Name: sk, + CommitId: v1types.CommitID{ + Version: int64(version), + Hash: commitBz, + }, + }) + } + + sort.SliceStable(storeInfos, func(i, j int) bool { + return strings.Compare(storeInfos[i].Name, storeInfos[j].Name) < 0 + }) + + return &v1types.CommitInfo{ + Version: int64(version), + StoreInfos: storeInfos, + }, nil } From cfc1c5f6c9e42b6898bfc23065eb34ce8b78c093 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Sep 2023 12:15:36 -0700 Subject: [PATCH 14/50] updates --- store/go.mod | 35 ++++++---- store/go.sum | 193 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 174 insertions(+), 54 deletions(-) diff --git a/store/go.mod b/store/go.mod index 3e4a169d6e77..a1170d47261f 100644 --- a/store/go.mod +++ b/store/go.mod @@ -5,12 +5,13 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/log v1.2.0 + cosmossdk.io/store v1.0.0-rc.0 github.com/cockroachdb/errors v1.11.1 github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c github.com/cometbft/cometbft v0.38.0-rc3 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/gogoproto v1.4.11 - github.com/cosmos/iavl v1.0.0-beta.2 + github.com/cosmos/iavl v1.0.0-rc.1 github.com/cosmos/ics23/go v0.10.0 github.com/linxGnu/grocksdb v1.8.0 github.com/stretchr/testify v1.8.4 @@ -18,7 +19,8 @@ require ( ) require ( - github.com/DataDog/zstd v1.4.5 // indirect + cosmossdk.io/math v1.1.2 // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -26,44 +28,47 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emicklei/dot v1.4.2 // indirect - github.com/getsentry/sentry-go v0.18.0 // indirect + github.com/getsentry/sentry-go v0.21.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/go-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-metrics v0.5.1 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.16.5 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae // indirect - github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect + github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/rs/zerolog v1.30.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect golang.org/x/crypto v0.12.0 // indirect - golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb // indirect - golang.org/x/mod v0.11.0 // indirect + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.7.0 // indirect + golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/store/go.sum b/store/go.sum index 55fa0389d398..24fd1f80fdcf 100644 --- a/store/go.sum +++ b/store/go.sum @@ -2,16 +2,33 @@ cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= +cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= +cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= +cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= @@ -30,17 +47,17 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= -github.com/cosmos/iavl v1.0.0-beta.2 h1:XOsIM80Yyml/KifCXEYOy9tWCXwMAbLa91n6pReW07Y= -github.com/cosmos/iavl v1.0.0-beta.2/go.mod h1:EA97dJ07TBktRlG/iGzK6g1eCXNj1q3MGoFYkVzrwHE= +github.com/cosmos/iavl v1.0.0-rc.1 h1:5+73BEWW1gZOIUJKlk/1fpD4lOqqeFBA8KuV+NpkCpU= +github.com/cosmos/iavl v1.0.0-rc.1/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= @@ -48,16 +65,25 @@ github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6 github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4= +github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -65,6 +91,7 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= @@ -77,18 +104,40 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= +github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= @@ -101,110 +150,170 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:FatpGJD2jmJfhZiFDElaC0QhZUDQnxUeAwTGkfAHN3I= github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d h1:htwtWgtQo8YS6JFWWi2DNgY0RwSGJ1ruMoxY6CUUclk= +github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 h1:lv6/DhyiFFGsmzxbsUUTOkN29II+zeWHxvT8Lpdxsv0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= @@ -219,13 +328,19 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= From 45da8a0487f79ff3cac755dee2ca86a1db1c41c7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 10:15:27 -0700 Subject: [PATCH 15/50] updates --- store/commitment/README.md | 3 + store/go.mod | 8 +- store/go.sum | 81 ------- store/internal/conv/string.go | 26 +++ store/internal/conv/string_test.go | 54 +++++ store/internal/kv/helpers.go | 17 ++ store/internal/kv/kv.go | 39 ++++ store/internal/maps/bench_test.go | 13 ++ store/internal/maps/maps.go | 215 ++++++++++++++++++ store/internal/maps/maps_test.go | 104 +++++++++ store/internal/proofs/convert.go | 98 ++++++++ store/internal/proofs/convert_test.go | 105 +++++++++ store/internal/proofs/create.go | 102 +++++++++ store/internal/proofs/create_test.go | 125 ++++++++++ store/internal/proofs/helpers.go | 101 ++++++++ store/internal/tree/hash.go | 68 ++++++ store/multistore/commit_info.go | 69 ++++++ store/multistore/{store.go => multi_store.go} | 58 ++--- store/storage/README.md | 3 + 19 files changed, 1175 insertions(+), 114 deletions(-) create mode 100644 store/commitment/README.md create mode 100644 store/internal/conv/string.go create mode 100644 store/internal/conv/string_test.go create mode 100644 store/internal/kv/helpers.go create mode 100644 store/internal/kv/kv.go create mode 100644 store/internal/maps/bench_test.go create mode 100644 store/internal/maps/maps.go create mode 100644 store/internal/maps/maps_test.go create mode 100644 store/internal/proofs/convert.go create mode 100644 store/internal/proofs/convert_test.go create mode 100644 store/internal/proofs/create.go create mode 100644 store/internal/proofs/create_test.go create mode 100644 store/internal/proofs/helpers.go create mode 100644 store/internal/tree/hash.go create mode 100644 store/multistore/commit_info.go rename store/multistore/{store.go => multi_store.go} (83%) create mode 100644 store/storage/README.md diff --git a/store/commitment/README.md b/store/commitment/README.md new file mode 100644 index 000000000000..4843ef0db536 --- /dev/null +++ b/store/commitment/README.md @@ -0,0 +1,3 @@ +# State Commitment (SC) + +TODO diff --git a/store/go.mod b/store/go.mod index a1170d47261f..87d797d739f8 100644 --- a/store/go.mod +++ b/store/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/log v1.2.0 - cosmossdk.io/store v1.0.0-rc.0 + cosmossdk.io/math v1.1.2 github.com/cockroachdb/errors v1.11.1 github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c github.com/cometbft/cometbft v0.38.0-rc3 @@ -15,11 +15,11 @@ require ( github.com/cosmos/ics23/go v0.10.0 github.com/linxGnu/grocksdb v1.8.0 github.com/stretchr/testify v1.8.4 + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 modernc.org/sqlite v1.25.0 ) require ( - cosmossdk.io/math v1.1.2 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect @@ -38,9 +38,6 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/hashicorp/go-immutable-radix v1.0.0 // indirect - github.com/hashicorp/go-metrics v0.5.1 // indirect - github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -63,7 +60,6 @@ require ( github.com/spf13/cast v1.5.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect golang.org/x/crypto v0.12.0 // indirect - golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect diff --git a/store/go.sum b/store/go.sum index 24fd1f80fdcf..4338b4de0f1a 100644 --- a/store/go.sum +++ b/store/go.sum @@ -4,31 +4,19 @@ cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= -cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= @@ -70,20 +58,12 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4= github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -104,40 +84,20 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= -github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= -github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= @@ -150,14 +110,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -174,36 +128,21 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d h1:htwtWgtQo8YS6JFWWi2DNgY0RwSGJ1ruMoxY6CUUclk= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= @@ -217,26 +156,17 @@ github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= -github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -249,9 +179,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -262,23 +190,18 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -328,17 +251,13 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/store/internal/conv/string.go b/store/internal/conv/string.go new file mode 100644 index 000000000000..ab2b7f44b38a --- /dev/null +++ b/store/internal/conv/string.go @@ -0,0 +1,26 @@ +package conv + +import ( + "reflect" + "unsafe" +) + +// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes +// must not be altered after this function is called as it will cause a segmentation fault. +func UnsafeStrToBytes(s string) []byte { + var buf []byte + sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s)) + bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) + bufHdr.Data = sHdr.Data + bufHdr.Cap = sHdr.Len + bufHdr.Len = sHdr.Len + return buf +} + +// UnsafeBytesToStr is meant to make a zero allocation conversion +// from []byte -> string to speed up operations, it is not meant +// to be used generally, but for a specific pattern to delete keys +// from a map. +func UnsafeBytesToStr(b []byte) string { + return *(*string)(unsafe.Pointer(&b)) +} diff --git a/store/internal/conv/string_test.go b/store/internal/conv/string_test.go new file mode 100644 index 000000000000..3a1451753188 --- /dev/null +++ b/store/internal/conv/string_test.go @@ -0,0 +1,54 @@ +package conv + +import ( + "runtime" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/suite" +) + +func TestStringSuite(t *testing.T) { + suite.Run(t, new(StringSuite)) +} + +type StringSuite struct{ suite.Suite } + +func unsafeConvertStr() []byte { + return UnsafeStrToBytes("abc") +} + +func (s *StringSuite) TestUnsafeStrToBytes() { + // we convert in other function to trigger GC. We want to check that + // the underlying array in []bytes is accessible after GC will finish swapping. + for i := 0; i < 5; i++ { + b := unsafeConvertStr() + runtime.GC() + <-time.NewTimer(2 * time.Millisecond).C + b2 := append(b, 'd') + s.Equal("abc", string(b)) + s.Equal("abcd", string(b2)) + } +} + +func unsafeConvertBytes() string { + return UnsafeBytesToStr([]byte("abc")) +} + +func (s *StringSuite) TestUnsafeBytesToStr() { + // we convert in other function to trigger GC. We want to check that + // the underlying array in []bytes is accessible after GC will finish swapping. + for i := 0; i < 5; i++ { + str := unsafeConvertBytes() + runtime.GC() + <-time.NewTimer(2 * time.Millisecond).C + s.Equal("abc", str) + } +} + +func BenchmarkUnsafeStrToBytes(b *testing.B) { + for i := 0; i < b.N; i++ { + UnsafeStrToBytes(strconv.Itoa(i)) + } +} diff --git a/store/internal/kv/helpers.go b/store/internal/kv/helpers.go new file mode 100644 index 000000000000..5bccea122eb5 --- /dev/null +++ b/store/internal/kv/helpers.go @@ -0,0 +1,17 @@ +package kv + +import "fmt" + +// AssertKeyAtLeastLength panics when store key length is less than the given length. +func AssertKeyAtLeastLength(bz []byte, length int) { + if len(bz) < length { + panic(fmt.Sprintf("expected key of length at least %d, got %d", length, len(bz))) + } +} + +// AssertKeyLength panics when store key length is not equal to the given length. +func AssertKeyLength(bz []byte, length int) { + if len(bz) != length { + panic(fmt.Sprintf("unexpected key length; got: %d, expected: %d", len(bz), length)) + } +} diff --git a/store/internal/kv/kv.go b/store/internal/kv/kv.go new file mode 100644 index 000000000000..de3bf5ca01c3 --- /dev/null +++ b/store/internal/kv/kv.go @@ -0,0 +1,39 @@ +package kv + +import ( + "bytes" + "sort" +) + +type ( + Pair struct { + Key []byte + Value []byte + } + + Pairs struct { + Pairs []Pair + } +) + +func (kvs Pairs) Len() int { return len(kvs.Pairs) } +func (kvs Pairs) Less(i, j int) bool { + switch bytes.Compare(kvs.Pairs[i].Key, kvs.Pairs[j].Key) { + case -1: + return true + + case 0: + return bytes.Compare(kvs.Pairs[i].Value, kvs.Pairs[j].Value) < 0 + + case 1: + return false + + default: + panic("invalid comparison result") + } +} + +func (kvs Pairs) Swap(i, j int) { kvs.Pairs[i], kvs.Pairs[j] = kvs.Pairs[j], kvs.Pairs[i] } + +// Sort invokes sort.Sort on kvs. +func (kvs Pairs) Sort() { sort.Sort(kvs) } diff --git a/store/internal/maps/bench_test.go b/store/internal/maps/bench_test.go new file mode 100644 index 000000000000..4d7f680c70c1 --- /dev/null +++ b/store/internal/maps/bench_test.go @@ -0,0 +1,13 @@ +package maps + +import "testing" + +func BenchmarkKVPairBytes(b *testing.B) { + kvp := NewKVPair(make([]byte, 128), make([]byte, 1e6)) + b.ResetTimer() + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + b.SetBytes(int64(len(kvp.Bytes()))) + } +} diff --git a/store/internal/maps/maps.go b/store/internal/maps/maps.go new file mode 100644 index 000000000000..0b016e664eb9 --- /dev/null +++ b/store/internal/maps/maps.go @@ -0,0 +1,215 @@ +package maps + +import ( + "encoding/binary" + + "cosmossdk.io/store/v2/internal/kv" + "cosmossdk.io/store/v2/internal/tree" + "github.com/cometbft/cometbft/crypto/merkle" + "github.com/cometbft/cometbft/crypto/tmhash" + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" +) + +// merkleMap defines a merkle-ized tree from a map. Leave values are treated as +// hash(key) | hash(value). Leaves are sorted before Merkle hashing. +type merkleMap struct { + kvs kv.Pairs + sorted bool +} + +func newMerkleMap() *merkleMap { + return &merkleMap{ + kvs: kv.Pairs{}, + sorted: false, + } +} + +// Set creates a kv.Pair from the provided key and value. The value is hashed prior +// to creating a kv.Pair. The created kv.Pair is appended to the MerkleMap's slice +// of kv.Pairs. Whenever called, the MerkleMap must be resorted. +func (sm *merkleMap) set(key string, value []byte) { + byteKey := []byte(key) + assertValidKey(byteKey) + + sm.sorted = false + + // The value is hashed, so you can check for equality with a cached value (say) + // and make a determination to fetch or not. + vhash := tmhash.Sum(value) + + sm.kvs.Pairs = append(sm.kvs.Pairs, kv.Pair{ + Key: byteKey, + Value: vhash, + }) +} + +// Hash returns the merkle root of items sorted by key. Note, it is unstable. +func (sm *merkleMap) hash() []byte { + sm.sort() + return hashKVPairs(sm.kvs) +} + +func (sm *merkleMap) sort() { + if sm.sorted { + return + } + + sm.kvs.Sort() + sm.sorted = true +} + +// hashKVPairs hashes a kvPair and creates a merkle tree where the leaves are +// byte slices. +func hashKVPairs(kvs kv.Pairs) []byte { + kvsH := make([][]byte, len(kvs.Pairs)) + for i, kvp := range kvs.Pairs { + kvsH[i] = KVPair(kvp).Bytes() + } + + return tree.HashFromByteSlices(kvsH) +} + +// --------------------------------------------- + +// Merkle tree from a map. +// Leaves are `hash(key) | hash(value)`. +// Leaves are sorted before Merkle hashing. +type simpleMap struct { + Kvs kv.Pairs + sorted bool +} + +func newSimpleMap() *simpleMap { + return &simpleMap{ + Kvs: kv.Pairs{}, + sorted: false, + } +} + +// Set creates a kv pair of the key and the hash of the value, +// and then appends it to SimpleMap's kv pairs. +func (sm *simpleMap) Set(key string, value []byte) { + byteKey := []byte(key) + assertValidKey(byteKey) + sm.sorted = false + + // The value is hashed, so you can + // check for equality with a cached value (say) + // and make a determination to fetch or not. + vhash := tmhash.Sum(value) + + sm.Kvs.Pairs = append(sm.Kvs.Pairs, kv.Pair{ + Key: byteKey, + Value: vhash, + }) +} + +// Hash Merkle root hash of items sorted by key +// (UNSTABLE: and by value too if duplicate key). +func (sm *simpleMap) Hash() []byte { + sm.Sort() + return hashKVPairs(sm.Kvs) +} + +func (sm *simpleMap) Sort() { + if sm.sorted { + return + } + sm.Kvs.Sort() + sm.sorted = true +} + +// Returns a copy of sorted KVPairs. +// NOTE these contain the hashed key and value. +func (sm *simpleMap) KVPairs() kv.Pairs { + sm.Sort() + kvs := kv.Pairs{ + Pairs: make([]kv.Pair, len(sm.Kvs.Pairs)), + } + + copy(kvs.Pairs, sm.Kvs.Pairs) + return kvs +} + +//---------------------------------------- + +// A local extension to KVPair that can be hashed. +// Key and value are length prefixed and concatenated, +// then hashed. +type KVPair kv.Pair + +// NewKVPair takes in a key and value and creates a kv.Pair +// wrapped in the local extension KVPair +func NewKVPair(key, value []byte) KVPair { + return KVPair(kv.Pair{ + Key: key, + Value: value, + }) +} + +// Bytes returns key || value, with both the +// key and value length prefixed. +func (kv KVPair) Bytes() []byte { + // In the worst case: + // * 8 bytes to Uvarint encode the length of the key + // * 8 bytes to Uvarint encode the length of the value + // So preallocate for the worst case, which will in total + // be a maximum of 14 bytes wasted, if len(key)=1, len(value)=1, + // but that's going to rare. + buf := make([]byte, 8+len(kv.Key)+8+len(kv.Value)) + + // Encode the key, prefixed with its length. + nlk := binary.PutUvarint(buf, uint64(len(kv.Key))) + nk := copy(buf[nlk:], kv.Key) + + // Encode the value, prefixing with its length. + nlv := binary.PutUvarint(buf[nlk+nk:], uint64(len(kv.Value))) + nv := copy(buf[nlk+nk+nlv:], kv.Value) + + return buf[:nlk+nk+nlv+nv] +} + +// HashFromMap computes a merkle tree from sorted map and returns the merkle +// root. +func HashFromMap(m map[string][]byte) []byte { + mm := newMerkleMap() + for k, v := range m { + mm.set(k, v) + } + + return mm.hash() +} + +// ProofsFromMap generates proofs from a map. The keys/values of the map will be used as the keys/values +// in the underlying key-value pairs. +// The keys are sorted before the proofs are computed. +func ProofsFromMap(m map[string][]byte) ([]byte, map[string]*cmtprotocrypto.Proof, []string) { + sm := newSimpleMap() + for k, v := range m { + sm.Set(k, v) + } + + sm.Sort() + kvs := sm.Kvs + kvsBytes := make([][]byte, len(kvs.Pairs)) + for i, kvp := range kvs.Pairs { + kvsBytes[i] = KVPair(kvp).Bytes() + } + + rootHash, proofList := merkle.ProofsFromByteSlices(kvsBytes) + proofs := make(map[string]*cmtprotocrypto.Proof) + keys := make([]string, len(proofList)) + + for i, kvp := range kvs.Pairs { + proofs[string(kvp.Key)] = proofList[i].ToProto() + keys[i] = string(kvp.Key) + } + + return rootHash, proofs, keys +} + +func assertValidKey(key []byte) { + if len(key) == 0 { + panic("key is nil") + } +} diff --git a/store/internal/maps/maps_test.go b/store/internal/maps/maps_test.go new file mode 100644 index 000000000000..ce7ad72e649d --- /dev/null +++ b/store/internal/maps/maps_test.go @@ -0,0 +1,104 @@ +package maps + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestEmptyKeyMerkleMap(t *testing.T) { + db := newMerkleMap() + require.Panics(t, func() { db.set("", []byte("value")) }, "setting an empty key should panic") +} + +func TestMerkleMap(t *testing.T) { + tests := []struct { + keys []string + values []string // each string gets converted to []byte in test + want string + }{ + {[]string{}, []string{}, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + {[]string{"key1"}, []string{"value1"}, "a44d3cc7daba1a4600b00a2434b30f8b970652169810d6dfa9fb1793a2189324"}, + {[]string{"key1"}, []string{"value2"}, "0638e99b3445caec9d95c05e1a3fc1487b4ddec6a952ff337080360b0dcc078c"}, + // swap order with 2 keys + { + []string{"key1", "key2"}, + []string{"value1", "value2"}, + "8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3", + }, + { + []string{"key2", "key1"}, + []string{"value2", "value1"}, + "8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3", + }, + // swap order with 3 keys + { + []string{"key1", "key2", "key3"}, + []string{"value1", "value2", "value3"}, + "1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc", + }, + { + []string{"key1", "key3", "key2"}, + []string{"value1", "value3", "value2"}, + "1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc", + }, + } + for i, tc := range tests { + db := newMerkleMap() + for i := 0; i < len(tc.keys); i++ { + db.set(tc.keys[i], []byte(tc.values[i])) + } + + got := db.hash() + assert.Equal(t, tc.want, fmt.Sprintf("%x", got), "Hash didn't match on tc %d", i) + } +} + +func TestEmptyKeySimpleMap(t *testing.T) { + db := newSimpleMap() + require.Panics(t, func() { db.Set("", []byte("value")) }, "setting an empty key should panic") +} + +func TestSimpleMap(t *testing.T) { + tests := []struct { + keys []string + values []string // each string gets converted to []byte in test + want string + }{ + {[]string{}, []string{}, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + {[]string{"key1"}, []string{"value1"}, "a44d3cc7daba1a4600b00a2434b30f8b970652169810d6dfa9fb1793a2189324"}, + {[]string{"key1"}, []string{"value2"}, "0638e99b3445caec9d95c05e1a3fc1487b4ddec6a952ff337080360b0dcc078c"}, + // swap order with 2 keys + { + []string{"key1", "key2"}, + []string{"value1", "value2"}, + "8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3", + }, + { + []string{"key2", "key1"}, + []string{"value2", "value1"}, + "8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3", + }, + // swap order with 3 keys + { + []string{"key1", "key2", "key3"}, + []string{"value1", "value2", "value3"}, + "1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc", + }, + { + []string{"key1", "key3", "key2"}, + []string{"value1", "value3", "value2"}, + "1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc", + }, + } + for i, tc := range tests { + db := newSimpleMap() + for i := 0; i < len(tc.keys); i++ { + db.Set(tc.keys[i], []byte(tc.values[i])) + } + got := db.Hash() + assert.Equal(t, tc.want, fmt.Sprintf("%x", got), "Hash didn't match on tc %d", i) + } +} diff --git a/store/internal/proofs/convert.go b/store/internal/proofs/convert.go new file mode 100644 index 000000000000..05cd60434168 --- /dev/null +++ b/store/internal/proofs/convert.go @@ -0,0 +1,98 @@ +package proofs + +import ( + "fmt" + "math/bits" + + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + ics23 "github.com/cosmos/ics23/go" +) + +// ConvertExistenceProof will convert the given proof into a valid +// existence proof, if that's what it is. +// +// This is the simplest case of the range proof and we will focus on +// demoing compatibility here +func ConvertExistenceProof(p *cmtprotocrypto.Proof, key, value []byte) (*ics23.ExistenceProof, error) { + path, err := convertInnerOps(p) + if err != nil { + return nil, err + } + + proof := &ics23.ExistenceProof{ + Key: key, + Value: value, + Leaf: convertLeafOp(), + Path: path, + } + return proof, nil +} + +// this is adapted from merkle/hash.go:leafHash() +// and merkle/simple_map.go:KVPair.Bytes() +func convertLeafOp() *ics23.LeafOp { + prefix := []byte{0} + + return &ics23.LeafOp{ + Hash: ics23.HashOp_SHA256, + PrehashKey: ics23.HashOp_NO_HASH, + PrehashValue: ics23.HashOp_SHA256, + Length: ics23.LengthOp_VAR_PROTO, + Prefix: prefix, + } +} + +func convertInnerOps(p *cmtprotocrypto.Proof) ([]*ics23.InnerOp, error) { + inners := make([]*ics23.InnerOp, 0, len(p.Aunts)) + path := buildPath(p.Index, p.Total) + + if len(p.Aunts) != len(path) { + return nil, fmt.Errorf("calculated a path different length (%d) than provided by SimpleProof (%d)", len(path), len(p.Aunts)) + } + + for i, aunt := range p.Aunts { + auntRight := path[i] + + // combine with: 0x01 || lefthash || righthash + inner := &ics23.InnerOp{Hash: ics23.HashOp_SHA256} + if auntRight { + inner.Prefix = []byte{1} + inner.Suffix = aunt + } else { + inner.Prefix = append([]byte{1}, aunt...) + } + inners = append(inners, inner) + } + return inners, nil +} + +// buildPath returns a list of steps from leaf to root +// in each step, true means index is left side, false index is right side +// code adapted from merkle/simple_proof.go:computeHashFromAunts +func buildPath(idx, total int64) []bool { + if total < 2 { + return nil + } + numLeft := getSplitPoint(total) + goLeft := idx < numLeft + + // we put goLeft at the end of the array, as we recurse from top to bottom, + // and want the leaf to be first in array, root last + if goLeft { + return append(buildPath(idx, numLeft), goLeft) + } + return append(buildPath(idx-numLeft, total-numLeft), goLeft) +} + +func getSplitPoint(length int64) int64 { + if length < 1 { + panic("Trying to split a tree with size < 1") + } + uLength := uint(length) + bitlen := bits.Len(uLength) + k := int64(1 << uint(bitlen-1)) + if k == length { + k >>= 1 + } + return k +} diff --git a/store/internal/proofs/convert_test.go b/store/internal/proofs/convert_test.go new file mode 100644 index 000000000000..19c5a6761507 --- /dev/null +++ b/store/internal/proofs/convert_test.go @@ -0,0 +1,105 @@ +package proofs + +import ( + "bytes" + "fmt" + "testing" +) + +func TestLeafOp(t *testing.T) { + proof := GenerateRangeProof(20, Middle) + + converted, err := ConvertExistenceProof(proof.Proof, proof.Key, proof.Value) + if err != nil { + t.Fatal(err) + } + + leaf := converted.GetLeaf() + if leaf == nil { + t.Fatalf("Missing leaf node") + } + + hash, err := leaf.Apply(converted.Key, converted.Value) + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(hash, proof.Proof.LeafHash) { + t.Errorf("Calculated: %X\nExpected: %X", hash, proof.Proof.LeafHash) + } +} + +func TestBuildPath(t *testing.T) { + cases := map[string]struct { + idx int64 + total int64 + expected []bool + }{ + "pair left": { + idx: 0, + total: 2, + expected: []bool{true}, + }, + "pair right": { + idx: 1, + total: 2, + expected: []bool{false}, + }, + "power of 2": { + idx: 3, + total: 8, + expected: []bool{false, false, true}, + }, + "size of 7 right most": { + idx: 6, + total: 7, + expected: []bool{false, false}, + }, + "size of 6 right-left (from top)": { + idx: 4, + total: 6, + expected: []bool{true, false}, + }, + "size of 6 left-right-left (from top)": { + idx: 2, + total: 7, + expected: []bool{true, false, true}, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + path := buildPath(tc.idx, tc.total) + if len(path) != len(tc.expected) { + t.Fatalf("Got %v\nExpected %v", path, tc.expected) + } + for i := range path { + if path[i] != tc.expected[i] { + t.Fatalf("Differ at %d\nGot %v\nExpected %v", i, path, tc.expected) + } + } + }) + } +} + +func TestConvertProof(t *testing.T) { + for i := 0; i < 100; i++ { + t.Run(fmt.Sprintf("Run %d", i), func(t *testing.T) { + proof := GenerateRangeProof(57, Left) + + converted, err := ConvertExistenceProof(proof.Proof, proof.Key, proof.Value) + if err != nil { + t.Fatal(err) + } + + calc, err := converted.Calculate() + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(calc, proof.RootHash) { + t.Errorf("Calculated: %X\nExpected: %X", calc, proof.RootHash) + } + }) + } +} diff --git a/store/internal/proofs/create.go b/store/internal/proofs/create.go new file mode 100644 index 000000000000..805b5257a4de --- /dev/null +++ b/store/internal/proofs/create.go @@ -0,0 +1,102 @@ +package proofs + +import ( + "errors" + "sort" + + "cosmossdk.io/store/v2/internal/maps" + ics23 "github.com/cosmos/ics23/go" +) + +var ( + ErrEmptyKey = errors.New("key is empty") + ErrEmptyKeyInData = errors.New("data contains empty key") +) + +/* +CreateMembershipProof will produce a CommitmentProof that the given key (and queries value) exists in the map. +If the key doesn't exist in the tree, this will return an error. +*/ +func CreateMembershipProof(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error) { + if len(key) == 0 { + return nil, ErrEmptyKey + } + exist, err := createExistenceProof(data, key) + if err != nil { + return nil, err + } + proof := &ics23.CommitmentProof{ + Proof: &ics23.CommitmentProof_Exist{ + Exist: exist, + }, + } + return proof, nil +} + +/* +CreateNonMembershipProof will produce a CommitmentProof that the given key doesn't exist in the map. +If the key exists in the tree, this will return an error. +*/ +func CreateNonMembershipProof(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error) { + if len(key) == 0 { + return nil, ErrEmptyKey + } + // ensure this key is not in the store + if _, ok := data[string(key)]; ok { + return nil, errors.New("cannot create non-membership proof if key is in map") + } + + keys := SortedKeys(data) + rightidx := sort.SearchStrings(keys, string(key)) + + var err error + nonexist := &ics23.NonExistenceProof{ + Key: key, + } + + // include left proof unless key is left of entire map + if rightidx >= 1 { + leftkey := keys[rightidx-1] + nonexist.Left, err = createExistenceProof(data, []byte(leftkey)) + if err != nil { + return nil, err + } + } + + // include right proof unless key is right of entire map + if rightidx < len(keys) { + rightkey := keys[rightidx] + nonexist.Right, err = createExistenceProof(data, []byte(rightkey)) + if err != nil { + return nil, err + } + + } + + proof := &ics23.CommitmentProof{ + Proof: &ics23.CommitmentProof_Nonexist{ + Nonexist: nonexist, + }, + } + return proof, nil +} + +func createExistenceProof(data map[string][]byte, key []byte) (*ics23.ExistenceProof, error) { + for k := range data { + if k == "" { + return nil, ErrEmptyKeyInData + } + } + value, ok := data[string(key)] + if !ok { + return nil, errors.New("cannot make existence proof if key is not in map") + } + + _, proofs, _ := maps.ProofsFromMap(data) + proof := proofs[string(key)] + if proof == nil { + return nil, errors.New("returned no proof for key") + } + + return ConvertExistenceProof(proof, key, value) +} diff --git a/store/internal/proofs/create_test.go b/store/internal/proofs/create_test.go new file mode 100644 index 000000000000..16818e657a81 --- /dev/null +++ b/store/internal/proofs/create_test.go @@ -0,0 +1,125 @@ +package proofs + +import ( + "errors" + "testing" + + ics23 "github.com/cosmos/ics23/go" + "github.com/stretchr/testify/assert" +) + +func TestCreateMembership(t *testing.T) { + cases := map[string]struct { + size int + loc Where + }{ + "small left": {size: 100, loc: Left}, + "small middle": {size: 100, loc: Middle}, + "small right": {size: 100, loc: Right}, + "big left": {size: 5431, loc: Left}, + "big middle": {size: 5431, loc: Middle}, + "big right": {size: 5431, loc: Right}, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + data := BuildMap(tc.size) + allkeys := SortedKeys(data) + key := GetKey(allkeys, tc.loc) + nonKey := GetNonKey(allkeys, tc.loc) + + // error if the key does not exist + proof, err := CreateMembershipProof(data, []byte(nonKey)) + assert.EqualError(t, err, "cannot make existence proof if key is not in map") + assert.Nil(t, proof) + + val := data[key] + proof, err = CreateMembershipProof(data, []byte(key)) + if err != nil { + t.Fatalf("Creating Proof: %+v", err) + } + if proof.GetExist() == nil { + t.Fatal("Unexpected proof format") + } + + root := CalcRoot(data) + err = proof.GetExist().Verify(ics23.TendermintSpec, root, []byte(key), val) + if err != nil { + t.Fatalf("Verifying Proof: %+v", err) + } + + valid := ics23.VerifyMembership(ics23.TendermintSpec, root, proof, []byte(key), val) + if !valid { + t.Fatalf("Membership Proof Invalid") + } + }) + } +} + +func TestCreateNonMembership(t *testing.T) { + cases := map[string]struct { + size int + loc Where + }{ + "small left": {size: 100, loc: Left}, + "small middle": {size: 100, loc: Middle}, + "small right": {size: 100, loc: Right}, + "big left": {size: 5431, loc: Left}, + "big middle": {size: 5431, loc: Middle}, + "big right": {size: 5431, loc: Right}, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + data := BuildMap(tc.size) + allkeys := SortedKeys(data) + nonKey := GetNonKey(allkeys, tc.loc) + key := GetKey(allkeys, tc.loc) + + // error if the key exists + proof, err := CreateNonMembershipProof(data, []byte(key)) + assert.EqualError(t, err, "cannot create non-membership proof if key is in map") + assert.Nil(t, proof) + + proof, err = CreateNonMembershipProof(data, []byte(nonKey)) + if err != nil { + t.Fatalf("Creating Proof: %+v", err) + } + if proof.GetNonexist() == nil { + t.Fatal("Unexpected proof format") + } + + root := CalcRoot(data) + err = proof.GetNonexist().Verify(ics23.TendermintSpec, root, []byte(nonKey)) + if err != nil { + t.Fatalf("Verifying Proof: %+v", err) + } + + valid := ics23.VerifyNonMembership(ics23.TendermintSpec, root, proof, []byte(nonKey)) + if !valid { + t.Fatalf("Non Membership Proof Invalid") + } + }) + } +} + +func TestInvalidKey(t *testing.T) { + tests := []struct { + name string + f func(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error) + data map[string][]byte + key []byte + err error + }{ + {"CreateMembershipProof empty key", CreateMembershipProof, map[string][]byte{"": nil}, []byte(""), ErrEmptyKey}, + {"CreateMembershipProof empty key in data", CreateMembershipProof, map[string][]byte{"": nil, " ": nil}, []byte(" "), ErrEmptyKeyInData}, + {"CreateNonMembershipProof empty key", CreateNonMembershipProof, map[string][]byte{" ": nil}, []byte(""), ErrEmptyKey}, + {"CreateNonMembershipProof empty key in data", CreateNonMembershipProof, map[string][]byte{"": nil}, []byte(" "), ErrEmptyKeyInData}, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + _, err := tc.f(tc.data, tc.key) + assert.True(t, errors.Is(err, tc.err)) + }) + } +} diff --git a/store/internal/proofs/helpers.go b/store/internal/proofs/helpers.go new file mode 100644 index 000000000000..1a7d8a36aac2 --- /dev/null +++ b/store/internal/proofs/helpers.go @@ -0,0 +1,101 @@ +package proofs + +import ( + "sort" + + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + "golang.org/x/exp/maps" + + "cosmossdk.io/math/unsafe" + internalmaps "cosmossdk.io/store/v2/internal/maps" +) + +// SimpleResult contains a merkle.SimpleProof along with all data needed to build the confio/proof +type SimpleResult struct { + Key []byte + Value []byte + Proof *cmtprotocrypto.Proof + RootHash []byte +} + +// GenerateRangeProof makes a tree of size and returns a range proof for one random element +// +// returns a range proof and the root hash of the tree +func GenerateRangeProof(size int, loc Where) *SimpleResult { + data := BuildMap(size) + root, proofs, allkeys := internalmaps.ProofsFromMap(data) + + key := GetKey(allkeys, loc) + proof := proofs[key] + + res := &SimpleResult{ + Key: []byte(key), + Value: toValue(key), + Proof: proof, + RootHash: root, + } + return res +} + +// Where selects a location for a key - Left, Right, or Middle +type Where int + +const ( + Left Where = iota + Right + Middle +) + +func SortedKeys(data map[string][]byte) []string { + keys := maps.Keys(data) + sort.Strings(keys) + return keys +} + +func CalcRoot(data map[string][]byte) []byte { + root, _, _ := internalmaps.ProofsFromMap(data) + return root +} + +// GetKey this returns a key, on Left/Right/Middle +func GetKey(allkeys []string, loc Where) string { + if loc == Left { + return allkeys[0] + } + if loc == Right { + return allkeys[len(allkeys)-1] + } + // select a random index between 1 and allkeys-2 + idx := unsafe.NewRand().Int()%(len(allkeys)-2) + 1 + return allkeys[idx] +} + +// GetNonKey returns a missing key - Left of all, Right of all, or in the Middle +func GetNonKey(allkeys []string, loc Where) string { + if loc == Left { + return string([]byte{1, 1, 1, 1}) + } + if loc == Right { + return string([]byte{0xff, 0xff, 0xff, 0xff}) + } + // otherwise, next to an existing key (copy before mod) + key := GetKey(allkeys, loc) + key = key[:len(key)-2] + string([]byte{255, 255}) + return key +} + +func toValue(key string) []byte { + return []byte("value_for_" + key) +} + +// BuildMap creates random key/values and stores in a map, +// returns a list of all keys in sorted order +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 := unsafe.Str(20) + data[key] = toValue(key) + } + return data +} diff --git a/store/internal/tree/hash.go b/store/internal/tree/hash.go new file mode 100644 index 000000000000..a4facd93e9b6 --- /dev/null +++ b/store/internal/tree/hash.go @@ -0,0 +1,68 @@ +package tree + +import ( + "crypto/sha256" + "hash" + "math/bits" +) + +var ( + leafPrefix = []byte{0} + innerPrefix = []byte{1} +) + +// HashFromByteSlices computes a Merkle tree where the leaves are the byte slice, +// in the provided order. It follows RFC-6962. +func HashFromByteSlices(items [][]byte) []byte { + return hashFromByteSlices(sha256.New(), items) +} + +func hashFromByteSlices(sha hash.Hash, items [][]byte) []byte { + switch len(items) { + case 0: + return emptyHash() + case 1: + return leafHashOpt(sha, items[0]) + default: + k := getSplitPoint(int64(len(items))) + left := hashFromByteSlices(sha, items[:k]) + right := hashFromByteSlices(sha, items[k:]) + return innerHashOpt(sha, left, right) + } +} + +// returns tmhash(0x00 || leaf) +func leafHashOpt(s hash.Hash, leaf []byte) []byte { + s.Reset() + s.Write(leafPrefix) + s.Write(leaf) + return s.Sum(nil) +} + +func innerHashOpt(s hash.Hash, left, right []byte) []byte { + s.Reset() + s.Write(innerPrefix) + s.Write(left) + s.Write(right) + return s.Sum(nil) +} + +// returns tmhash() +func emptyHash() []byte { + h := sha256.Sum256([]byte{}) + return h[:] +} + +// getSplitPoint returns the largest power of 2 less than length +func getSplitPoint(length int64) int64 { + if length < 1 { + panic("Trying to split a tree with size < 1") + } + uLength := uint(length) + bitlen := bits.Len(uLength) + k := int64(1 << uint(bitlen-1)) + if k == length { + k >>= 1 + } + return k +} diff --git a/store/multistore/commit_info.go b/store/multistore/commit_info.go new file mode 100644 index 000000000000..1e5900e2bdd3 --- /dev/null +++ b/store/multistore/commit_info.go @@ -0,0 +1,69 @@ +package multistore + +import ( + "time" + + "cosmossdk.io/store/v2/internal/maps" +) + +type ( + // CommitInfo defines commit information used by the multi-store when committing + // a version/height. + CommitInfo struct { + Version uint64 + StoreInfos []StoreInfo + Timestamp time.Time + } + + // StoreInfo defines store-specific commit information. It contains a reference + // between a store name/key and the commit ID. + StoreInfo struct { + Name string + CommitID CommitID + } + + // CommitID defines the commitment information when a specific store is + // committed. + CommitID struct { + Version uint64 + Hash []byte + } +) + +func (si StoreInfo) GetHash() []byte { + return si.CommitID.Hash +} + +// Hash returns the root hash of all committed stores represented by CommitInfo, +// sorted by store name/key. +func (ci CommitInfo) Hash() []byte { + if len(ci.StoreInfos) == 0 { + return nil + } + + rootHash, _, _ := maps.ProofsFromMap(ci.toMap()) + return rootHash +} + +func (ci CommitInfo) toMap() map[string][]byte { + m := make(map[string][]byte, len(ci.StoreInfos)) + for _, storeInfo := range ci.StoreInfos { + m[storeInfo.Name] = storeInfo.GetHash() + } + + return m +} + +func (ci CommitInfo) CommitID() CommitID { + return CommitID{ + Version: ci.Version, + Hash: ci.Hash(), + } +} + +func (m *CommitInfo) GetVersion() uint64 { + if m != nil { + return m.Version + } + return 0 +} diff --git a/store/multistore/store.go b/store/multistore/multi_store.go similarity index 83% rename from store/multistore/store.go rename to store/multistore/multi_store.go index 0946275a8625..d47d488f6437 100644 --- a/store/multistore/store.go +++ b/store/multistore/multi_store.go @@ -8,7 +8,6 @@ import ( "time" "cosmossdk.io/log" - v1types "cosmossdk.io/store/types" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" "github.com/cockroachdb/errors" @@ -21,7 +20,6 @@ type ( // // TODO: // - Move relevant types to the 'core' package. - // - Remove reliance on store v1 types. MultiStore interface { GetSCStore(storeKey string) *commitment.Database MountSCStore(storeKey string, sc *commitment.Database) error @@ -34,9 +32,12 @@ type ( SetCommitHeader(h CommitHeader) // TODO: + // // - Tracing // - Branching // - Queries + // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 io.Closer } @@ -64,13 +65,13 @@ type Store struct { removalMap map[string]struct{} // lastCommitInfo reflects the last version/hash that has been committed - lastCommitInfo *v1types.CommitInfo + lastCommitInfo *CommitInfo } -func New(logger log.Logger, initialVersion uint64, ss store.VersionedDatabase) (MultiStore, error) { +func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (MultiStore, error) { return &Store{ logger: logger.With("module", "multi_store"), - initialVersion: initialVersion, + initialVersion: initVersion, ss: ss, scStores: make(map[string]*commitment.Database), removalMap: make(map[string]struct{}), @@ -107,23 +108,23 @@ func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { // LastCommitID returns a CommitID based off of the latest internal CommitInfo. // If an internal CommitInfo is not set, a new one will be returned with only the // latest version set, which is based off of the SS view. -func (s *Store) LastCommitID() (v1types.CommitID, error) { +func (s *Store) LastCommitID() (CommitID, error) { if s.lastCommitInfo == nil { - lv, err := s.ss.GetLatestVersion() + latestVersion, err := s.ss.GetLatestVersion() if err != nil { - return v1types.CommitID{}, err + return CommitID{}, err } // ensure integrity of latest version across all SC stores for sk, sc := range s.scStores { scVersion := sc.GetLatestVersion() - if scVersion != lv { - return v1types.CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, lv) + if scVersion != latestVersion { + return CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) } } - return v1types.CommitID{ - Version: int64(lv), + return CommitID{ + Version: latestVersion, }, nil } @@ -168,7 +169,7 @@ func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } -func (s *Store) loadVersion(v uint64, upgrades *v1types.StoreUpgrades) (err error) { +func (s *Store) loadVersion(v uint64, upgrades any) (err error) { s.logger.Debug("loading version", "version", v) for sk, sc := range s.scStores { @@ -179,18 +180,20 @@ func (s *Store) loadVersion(v uint64, upgrades *v1types.StoreUpgrades) (err erro // TODO: Complete this method to handle upgrades. See legacy RMS loadVersion() // for reference. + // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 return err } func (s *Store) WorkingHash() []byte { - storeInfos := make([]v1types.StoreInfo, 0, len(s.scStores)) + storeInfos := make([]StoreInfo, 0, len(s.scStores)) for sk, sc := range s.scStores { if _, ok := s.removalMap[sk]; ok { - storeInfos = append(storeInfos, v1types.StoreInfo{ + storeInfos = append(storeInfos, StoreInfo{ Name: sk, - CommitId: v1types.CommitID{ + CommitID: CommitID{ Hash: sc.WorkingHash(), }, }) @@ -201,7 +204,7 @@ func (s *Store) WorkingHash() []byte { return storeInfos[i].Name < storeInfos[j].Name }) - return v1types.CommitInfo{StoreInfos: storeInfos}.Hash() + return CommitInfo{StoreInfos: storeInfos}.Hash() } func (s *Store) SetCommitHeader(h CommitHeader) { @@ -221,7 +224,7 @@ func (s *Store) Commit() ([]byte, error) { // increment the version from there. // 2. There was no previous commit, and initial version was not set, in which // case we start at version 1. - previousHeight = uint64(s.lastCommitInfo.GetVersion()) + previousHeight = s.lastCommitInfo.GetVersion() version = previousHeight + 1 } @@ -243,7 +246,7 @@ func (s *Store) Commit() ([]byte, error) { s.removalMap = make(map[string]struct{}) // commit writes to SC stores - commitInfo, err := s.commitSC(version) + commitInfo, err := s.commitSCStores(version) if err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } @@ -256,16 +259,17 @@ func (s *Store) Commit() ([]byte, error) { return s.lastCommitInfo.Hash(), nil } -// commitSC commits each SC store individually and returns a CommitInfo +// commitSCStores commits each SC store individually and returns a CommitInfo // representing commitment of all the SC stores. Note, commitment is NOT atomic. // An error is returned if any SC store fails to commit. -func (s *Store) commitSC(version uint64) (*v1types.CommitInfo, error) { - storeInfos := make([]v1types.StoreInfo, 0, len(s.scStores)) +func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { + storeInfos := make([]StoreInfo, 0, len(s.scStores)) for sk, sc := range s.scStores { // TODO: Handle and support SC store last CommitID to handle the case where // a Commit is interrupted and a SC store could have a version that is ahead: // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 // scLastCommitID := sc.LastCommitID() // var commitID v1types.CommitID @@ -281,10 +285,10 @@ func (s *Store) commitSC(version uint64) (*v1types.CommitInfo, error) { return nil, fmt.Errorf("failed to commit SC store %s: %w", sk, err) } - storeInfos = append(storeInfos, v1types.StoreInfo{ + storeInfos = append(storeInfos, StoreInfo{ Name: sk, - CommitId: v1types.CommitID{ - Version: int64(version), + CommitID: CommitID{ + Version: version, Hash: commitBz, }, }) @@ -294,8 +298,8 @@ func (s *Store) commitSC(version uint64) (*v1types.CommitInfo, error) { return strings.Compare(storeInfos[i].Name, storeInfos[j].Name) < 0 }) - return &v1types.CommitInfo{ - Version: int64(version), + return &CommitInfo{ + Version: version, StoreInfos: storeInfos, }, nil } diff --git a/store/storage/README.md b/store/storage/README.md new file mode 100644 index 000000000000..c82c3f3a2fe2 --- /dev/null +++ b/store/storage/README.md @@ -0,0 +1,3 @@ +# State Storage (SS) + +TODO From 71fd8b29c71400da87f59666621d03d5ff83e1ca Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 10:18:42 -0700 Subject: [PATCH 16/50] updates --- store/multistore/multi_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/multistore/multi_store.go b/store/multistore/multi_store.go index d47d488f6437..0613a5e3fd17 100644 --- a/store/multistore/multi_store.go +++ b/store/multistore/multi_store.go @@ -140,7 +140,7 @@ func (s *Store) GetLatestVersion() (uint64, error) { return 0, err } - return uint64(lastCommitID.Version), nil + return lastCommitID.Version, nil } func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) { @@ -272,7 +272,7 @@ func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 // scLastCommitID := sc.LastCommitID() - // var commitID v1types.CommitID + // var commitID CommitID // if scLastCommitID.Version >= version { // scLastCommitID.Version = version // commitID = scLastCommitID From a8c1bef72d5ca8e8363614090c9eeee1ca50e068 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 10:20:28 -0700 Subject: [PATCH 17/50] updates --- store/multistore/multi_store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/multistore/multi_store.go b/store/multistore/multi_store.go index 0613a5e3fd17..60d4dc2ac132 100644 --- a/store/multistore/multi_store.go +++ b/store/multistore/multi_store.go @@ -190,7 +190,7 @@ func (s *Store) WorkingHash() []byte { storeInfos := make([]StoreInfo, 0, len(s.scStores)) for sk, sc := range s.scStores { - if _, ok := s.removalMap[sk]; ok { + if _, ok := s.removalMap[sk]; !ok { storeInfos = append(storeInfos, StoreInfo{ Name: sk, CommitID: CommitID{ From 1e9c0bdf70f5f9e6040d32482571ab8cbae373f7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 11:51:15 -0700 Subject: [PATCH 18/50] updates --- store/internal/conv/string.go | 26 -------------- store/internal/conv/string_test.go | 54 ------------------------------ store/multistore/multi_store.go | 27 +++++++++------ 3 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 store/internal/conv/string.go delete mode 100644 store/internal/conv/string_test.go diff --git a/store/internal/conv/string.go b/store/internal/conv/string.go deleted file mode 100644 index ab2b7f44b38a..000000000000 --- a/store/internal/conv/string.go +++ /dev/null @@ -1,26 +0,0 @@ -package conv - -import ( - "reflect" - "unsafe" -) - -// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes -// must not be altered after this function is called as it will cause a segmentation fault. -func UnsafeStrToBytes(s string) []byte { - var buf []byte - sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s)) - bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) - bufHdr.Data = sHdr.Data - bufHdr.Cap = sHdr.Len - bufHdr.Len = sHdr.Len - return buf -} - -// UnsafeBytesToStr is meant to make a zero allocation conversion -// from []byte -> string to speed up operations, it is not meant -// to be used generally, but for a specific pattern to delete keys -// from a map. -func UnsafeBytesToStr(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} diff --git a/store/internal/conv/string_test.go b/store/internal/conv/string_test.go deleted file mode 100644 index 3a1451753188..000000000000 --- a/store/internal/conv/string_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package conv - -import ( - "runtime" - "strconv" - "testing" - "time" - - "github.com/stretchr/testify/suite" -) - -func TestStringSuite(t *testing.T) { - suite.Run(t, new(StringSuite)) -} - -type StringSuite struct{ suite.Suite } - -func unsafeConvertStr() []byte { - return UnsafeStrToBytes("abc") -} - -func (s *StringSuite) TestUnsafeStrToBytes() { - // we convert in other function to trigger GC. We want to check that - // the underlying array in []bytes is accessible after GC will finish swapping. - for i := 0; i < 5; i++ { - b := unsafeConvertStr() - runtime.GC() - <-time.NewTimer(2 * time.Millisecond).C - b2 := append(b, 'd') - s.Equal("abc", string(b)) - s.Equal("abcd", string(b2)) - } -} - -func unsafeConvertBytes() string { - return UnsafeBytesToStr([]byte("abc")) -} - -func (s *StringSuite) TestUnsafeBytesToStr() { - // we convert in other function to trigger GC. We want to check that - // the underlying array in []bytes is accessible after GC will finish swapping. - for i := 0; i < 5; i++ { - str := unsafeConvertBytes() - runtime.GC() - <-time.NewTimer(2 * time.Millisecond).C - s.Equal("abc", str) - } -} - -func BenchmarkUnsafeStrToBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - UnsafeStrToBytes(strconv.Itoa(i)) - } -} diff --git a/store/multistore/multi_store.go b/store/multistore/multi_store.go index 60d4dc2ac132..5b56d410696c 100644 --- a/store/multistore/multi_store.go +++ b/store/multistore/multi_store.go @@ -233,18 +233,10 @@ func (s *Store) Commit() ([]byte, error) { } // remove and close all SC stores marked for removal - for sk := range s.removalMap { - if sc, ok := s.scStores[sk]; ok { - if err := sc.Close(); err != nil { - return nil, err - } - - delete(s.scStores, sk) - } + if err := s.clearRemovalMap(); err != nil { + return nil, err } - s.removalMap = make(map[string]struct{}) - // commit writes to SC stores commitInfo, err := s.commitSCStores(version) if err != nil { @@ -259,6 +251,21 @@ func (s *Store) Commit() ([]byte, error) { return s.lastCommitInfo.Hash(), nil } +func (s *Store) clearRemovalMap() error { + for sk := range s.removalMap { + if sc, ok := s.scStores[sk]; ok { + if err := sc.Close(); err != nil { + return err + } + + delete(s.scStores, sk) + } + } + + s.removalMap = make(map[string]struct{}) + return nil +} + // commitSCStores commits each SC store individually and returns a CommitInfo // representing commitment of all the SC stores. Note, commitment is NOT atomic. // An error is returned if any SC store fails to commit. From 986952338f639418046d87058aa57051f2a43758 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 12:06:12 -0700 Subject: [PATCH 19/50] updates --- store/multistore/{multi_store.go => store.go} | 29 ++++----- store/types/store_key.go | 59 +++++++++++++++++++ 2 files changed, 74 insertions(+), 14 deletions(-) rename store/multistore/{multi_store.go => store.go} (89%) create mode 100644 store/types/store_key.go diff --git a/store/multistore/multi_store.go b/store/multistore/store.go similarity index 89% rename from store/multistore/multi_store.go rename to store/multistore/store.go index 5b56d410696c..f38bd20a46f3 100644 --- a/store/multistore/multi_store.go +++ b/store/multistore/store.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/log" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" + "cosmossdk.io/store/v2/types" "github.com/cockroachdb/errors" ics23 "github.com/cosmos/ics23/go" ) @@ -21,9 +22,9 @@ type ( // TODO: // - Move relevant types to the 'core' package. MultiStore interface { - GetSCStore(storeKey string) *commitment.Database - MountSCStore(storeKey string, sc *commitment.Database) error - GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) + GetSCStore(storeKey types.StoreKey) *commitment.Database + MountSCStore(storeKey types.StoreKey, sc *commitment.Database) error + GetProof(storeKey types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error LoadLatestVersion() error GetLatestVersion() (uint64, error) @@ -59,10 +60,10 @@ type Store struct { ss store.VersionedDatabase // scStores reflect a mapping of store key to state commitment backend (i.e. a backend per module) - scStores map[string]*commitment.Database + scStores map[types.StoreKey]*commitment.Database // removalMap reflects module stores marked for removal - removalMap map[string]struct{} + removalMap map[types.StoreKey]struct{} // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *CommitInfo @@ -73,8 +74,8 @@ func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (Mul logger: logger.With("module", "multi_store"), initialVersion: initVersion, ss: ss, - scStores: make(map[string]*commitment.Database), - removalMap: make(map[string]struct{}), + scStores: make(map[types.StoreKey]*commitment.Database), + removalMap: make(map[types.StoreKey]struct{}), }, nil } @@ -95,8 +96,8 @@ func (s *Store) Close() (err error) { return err } -func (s *Store) MountSCStore(storeKey string, sc *commitment.Database) error { - s.logger.Debug("mounting store", "store_key", storeKey) +func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) error { + s.logger.Debug("mounting store", "store_key", storeKey.String()) if _, ok := s.scStores[storeKey]; ok { return fmt.Errorf("SC store with key %s already mounted", storeKey) } @@ -143,7 +144,7 @@ func (s *Store) GetLatestVersion() (uint64, error) { return lastCommitID.Version, nil } -func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) { +func (s *Store) GetProof(storeKey types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) { sc, ok := s.scStores[storeKey] if !ok { return nil, fmt.Errorf("SC store with key %s not mounted", storeKey) @@ -152,7 +153,7 @@ func (s *Store) GetProof(storeKey string, version uint64, key []byte) (*ics23.Co return sc.GetProof(version, key) } -func (s *Store) GetSCStore(storeKey string) *commitment.Database { +func (s *Store) GetSCStore(storeKey types.StoreKey) *commitment.Database { panic("not implemented!") } @@ -192,7 +193,7 @@ func (s *Store) WorkingHash() []byte { for sk, sc := range s.scStores { if _, ok := s.removalMap[sk]; !ok { storeInfos = append(storeInfos, StoreInfo{ - Name: sk, + Name: sk.Name(), CommitID: CommitID{ Hash: sc.WorkingHash(), }, @@ -262,7 +263,7 @@ func (s *Store) clearRemovalMap() error { } } - s.removalMap = make(map[string]struct{}) + s.removalMap = make(map[types.StoreKey]struct{}) return nil } @@ -293,7 +294,7 @@ func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { } storeInfos = append(storeInfos, StoreInfo{ - Name: sk, + Name: sk.Name(), CommitID: CommitID{ Version: version, Hash: commitBz, diff --git a/store/types/store_key.go b/store/types/store_key.go new file mode 100644 index 000000000000..9eaf4ae2190a --- /dev/null +++ b/store/types/store_key.go @@ -0,0 +1,59 @@ +package types + +import ( + "fmt" + "sort" + "strings" +) + +// StoreKey defines an interface for types that provide store keys. +type StoreKey interface { + Name() string + String() string +} + +// KVStoreKey is used for providing permissioned access to module stores. +type KVStoreKey struct { + name string +} + +func NewKVStoreKey(name string) *KVStoreKey { + if name == "" { + panic("empty key name not allowed") + } + + return &KVStoreKey{ + name: name, + } +} + +func NewKVStoreKeys(names ...string) map[string]*KVStoreKey { + assertNoCommonPrefix(names) + keys := make(map[string]*KVStoreKey, len(names)) + for _, n := range names { + keys[n] = NewKVStoreKey(n) + } + + return keys +} + +func (key *KVStoreKey) Name() string { + return key.name +} + +func (key *KVStoreKey) String() string { + return fmt.Sprintf("KVStoreKey{%p, %s}", key, key.name) +} + +func assertNoCommonPrefix(keys []string) { + sorted := make([]string, len(keys)) + + copy(sorted, keys) + sort.Strings(sorted) + + for i := 1; i < len(sorted); i++ { + if strings.HasPrefix(sorted[i], sorted[i-1]) { + panic(fmt.Errorf("potential key collision between KVStores: %s, %s", sorted[i], sorted[i-1])) + } + } +} From 499de87fa73b7f7dbcca74a295838f67b0504c8d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 12:29:59 -0700 Subject: [PATCH 20/50] updates --- store/multistore/store.go | 75 ++++++++++++++++++++++++++++++++-- store/types/kv_pair.go | 10 +++++ store/types/memory_listener.go | 27 ++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 store/types/kv_pair.go create mode 100644 store/types/memory_listener.go diff --git a/store/multistore/store.go b/store/multistore/store.go index f38bd20a46f3..b96b4b6649cd 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -67,6 +67,9 @@ type Store struct { // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *CommitInfo + + // memListeners reflect a mapping of store key to a memory listener, which is used to flush writes to SS + memListeners map[types.StoreKey]*types.MemoryListener } func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (MultiStore, error) { @@ -96,6 +99,9 @@ func (s *Store) Close() (err error) { return err } +// MountSCStore mounts a state commitment (SC) store to the multi-store. It will +// also create a new MemoryListener entry for the store key if one has not +// already been created. An error is returned if the SC store is already mounted. func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) error { s.logger.Debug("mounting store", "store_key", storeKey.String()) if _, ok := s.scStores[storeKey]; ok { @@ -103,6 +109,13 @@ func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) e } s.scStores[storeKey] = sc + + // Mount memory listener for the store key so we can flush accumulated writes + // to SS upon Commit. + if _, ok := s.memListeners[storeKey]; !ok { + s.memListeners[storeKey] = types.NewMemoryListener() + } + return nil } @@ -111,6 +124,9 @@ func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) e // latest version set, which is based off of the SS view. func (s *Store) LastCommitID() (CommitID, error) { if s.lastCommitInfo == nil { + // XXX/TODO: We cannot use SS to get the latest version when lastCommitInfo + // is nil if SS is flushed asynchronously. This is because the latest version + // in SS might not be the latest version in the SC stores. latestVersion, err := s.ss.GetLatestVersion() if err != nil { return CommitID{}, err @@ -212,6 +228,13 @@ func (s *Store) SetCommitHeader(h CommitHeader) { s.commitHeader = h } +// Commit commits all state changes to the underlying SS backend and all SC stores. +// Note, writes to the SS backend are retrieved from the SC memory listeners and +// are committed in a single batch synchronously. All writes to each SC are also +// committed synchronously, however, they are NOT atomic. A byte slice is returned +// reflecting the Merkle root hash of all committed SC stores. +// +// TODO: Explore flushing writes to SS asynchronously. func (s *Store) Commit() ([]byte, error) { var previousHeight, version uint64 if s.lastCommitInfo.GetVersion() == 0 && s.initialVersion > 1 { @@ -234,11 +257,11 @@ func (s *Store) Commit() ([]byte, error) { } // remove and close all SC stores marked for removal - if err := s.clearRemovalMap(); err != nil { - return nil, err + if err := s.clearSCRemovalMap(); err != nil { + return nil, fmt.Errorf("failed to clear SC removal map: %w", err) } - // commit writes to SC stores + // commit writes to all SC stores commitInfo, err := s.commitSCStores(version) if err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) @@ -248,11 +271,14 @@ func (s *Store) Commit() ([]byte, error) { s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() // TODO: Commit writes to SS backend asynchronously. + if err := s.commitSS(version); err != nil { + return nil, fmt.Errorf("failed to commit SS: %w", err) + } return s.lastCommitInfo.Hash(), nil } -func (s *Store) clearRemovalMap() error { +func (s *Store) clearSCRemovalMap() error { for sk := range s.removalMap { if sc, ok := s.scStores[sk]; ok { if err := sc.Close(); err != nil { @@ -267,6 +293,47 @@ func (s *Store) clearRemovalMap() error { return nil } +// PopStateCache returns all the accumulated writes from all SC stores. Note, +// calling popStateCache destroys only the currently accumulated state in each +// listener not the state in the store itself. This is a mutating and destructive +// operation. +func (rs *Store) popStateCache() []*types.StoreKVPair { + var writes []*types.StoreKVPair + for _, ml := range rs.memListeners { + if ml != nil { + writes = append(writes, ml.PopStateCache()...) + } + } + + sort.SliceStable(writes, func(i, j int) bool { + return writes[i].StoreKey < writes[j].StoreKey + }) + + return writes +} + +func (s *Store) commitSS(version uint64) error { + batch, err := s.ss.NewBatch(version) + if err != nil { + return err + } + + writes := s.popStateCache() + for _, skv := range writes { + if skv.Delete { + if err := batch.Delete(skv.StoreKey, skv.Key); err != nil { + return err + } + } else { + if err := batch.Set(skv.StoreKey, skv.Key, skv.Value); err != nil { + return err + } + } + } + + return batch.Write() +} + // commitSCStores commits each SC store individually and returns a CommitInfo // representing commitment of all the SC stores. Note, commitment is NOT atomic. // An error is returned if any SC store fails to commit. diff --git a/store/types/kv_pair.go b/store/types/kv_pair.go new file mode 100644 index 000000000000..7b34355f0afc --- /dev/null +++ b/store/types/kv_pair.go @@ -0,0 +1,10 @@ +package types + +// StoreKVPair defines a key-value pair with additional metadata that is used +// to track writes to an underlying SC store. +type StoreKVPair struct { + StoreKey string + Delete bool + Key []byte + Value []byte +} diff --git a/store/types/memory_listener.go b/store/types/memory_listener.go new file mode 100644 index 000000000000..32ed1fd1ba00 --- /dev/null +++ b/store/types/memory_listener.go @@ -0,0 +1,27 @@ +package types + +// MemoryListener listens to the state writes and accumulate the records in memory. +type MemoryListener struct { + stateCache []*StoreKVPair +} + +func NewMemoryListener() *MemoryListener { + return &MemoryListener{} +} + +// OnWrite records a state write in memory. +func (fl *MemoryListener) OnWrite(storeKey StoreKey, key, value []byte, delete bool) { + fl.stateCache = append(fl.stateCache, &StoreKVPair{ + StoreKey: storeKey.Name(), + Delete: delete, + Key: key, + Value: value, + }) +} + +// PopStateCache returns the current state caches and set to nil. +func (fl *MemoryListener) PopStateCache() []*StoreKVPair { + res := fl.stateCache + fl.stateCache = nil + return res +} From 2601546df131e6b1242c2cd6868143d06713dd94 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 12:34:58 -0700 Subject: [PATCH 21/50] updates --- store/multistore/store.go | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index b96b4b6649cd..60436e290e54 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -49,7 +49,7 @@ type ( } ) -var _ MultiStore = &Store{} +var _ MultiStore = (*Store)(nil) type Store struct { logger log.Logger @@ -123,29 +123,27 @@ func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) e // If an internal CommitInfo is not set, a new one will be returned with only the // latest version set, which is based off of the SS view. func (s *Store) LastCommitID() (CommitID, error) { - if s.lastCommitInfo == nil { - // XXX/TODO: We cannot use SS to get the latest version when lastCommitInfo - // is nil if SS is flushed asynchronously. This is because the latest version - // in SS might not be the latest version in the SC stores. - latestVersion, err := s.ss.GetLatestVersion() - if err != nil { - return CommitID{}, err - } + if s.lastCommitInfo != nil { + return s.lastCommitInfo.CommitID(), nil + } - // ensure integrity of latest version across all SC stores - for sk, sc := range s.scStores { - scVersion := sc.GetLatestVersion() - if scVersion != latestVersion { - return CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) - } - } + // XXX/TODO: We cannot use SS to get the latest version when lastCommitInfo + // is nil if SS is flushed asynchronously. This is because the latest version + // in SS might not be the latest version in the SC stores. + latestVersion, err := s.ss.GetLatestVersion() + if err != nil { + return CommitID{}, err + } - return CommitID{ - Version: latestVersion, - }, nil + // ensure integrity of latest version across all SC stores + for sk, sc := range s.scStores { + scVersion := sc.GetLatestVersion() + if scVersion != latestVersion { + return CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) + } } - return s.lastCommitInfo.CommitID(), nil + return CommitID{Version: latestVersion}, nil } // GetLatestVersion returns the latest version based on the latest internal From 4dd4c02e26279965f692f03e41d3e4e005ff2e17 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 12:37:44 -0700 Subject: [PATCH 22/50] updates --- store/multistore/store.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 60436e290e54..98ac1b71d204 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -276,11 +276,12 @@ func (s *Store) Commit() ([]byte, error) { return s.lastCommitInfo.Hash(), nil } -func (s *Store) clearSCRemovalMap() error { +func (s *Store) clearSCRemovalMap() (err error) { for sk := range s.removalMap { - if sc, ok := s.scStores[sk]; ok { - if err := sc.Close(); err != nil { - return err + sc, ok := s.scStores[sk] + if ok { + if ce := sc.Close(); ce != nil { + err = errors.Join(err, ce) } delete(s.scStores, sk) @@ -288,7 +289,7 @@ func (s *Store) clearSCRemovalMap() error { } s.removalMap = make(map[types.StoreKey]struct{}) - return nil + return err } // PopStateCache returns all the accumulated writes from all SC stores. Note, From e690be3042264159587c7bd237308a6acc1fcba0 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 20:10:10 -0700 Subject: [PATCH 23/50] updates --- store/multistore/store.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 98ac1b71d204..b4da45fe2440 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -231,8 +231,6 @@ func (s *Store) SetCommitHeader(h CommitHeader) { // are committed in a single batch synchronously. All writes to each SC are also // committed synchronously, however, they are NOT atomic. A byte slice is returned // reflecting the Merkle root hash of all committed SC stores. -// -// TODO: Explore flushing writes to SS asynchronously. func (s *Store) Commit() ([]byte, error) { var previousHeight, version uint64 if s.lastCommitInfo.GetVersion() == 0 && s.initialVersion > 1 { From b0b740b64dac8ae643aabaef84f35ec65899d29c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 20:10:39 -0700 Subject: [PATCH 24/50] updates --- store/multistore/store.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index b4da45fe2440..df9433efd8f0 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -130,6 +130,8 @@ func (s *Store) LastCommitID() (CommitID, error) { // XXX/TODO: We cannot use SS to get the latest version when lastCommitInfo // is nil if SS is flushed asynchronously. This is because the latest version // in SS might not be the latest version in the SC stores. + // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 latestVersion, err := s.ss.GetLatestVersion() if err != nil { return CommitID{}, err From 026c5e56fc0d22d821fc3ea5978f90deff0a740a Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 6 Sep 2023 20:11:14 -0700 Subject: [PATCH 25/50] updates --- store/multistore/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index df9433efd8f0..577dee0f495b 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -170,7 +170,7 @@ func (s *Store) GetProof(storeKey types.StoreKey, version uint64, key []byte) (* } func (s *Store) GetSCStore(storeKey types.StoreKey) *commitment.Database { - panic("not implemented!") + return s.scStores[storeKey] } func (s *Store) LoadLatestVersion() error { From 73c48dde1e81b5e9b1bae247df14e3c47ecdc459 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Sep 2023 10:05:48 -0700 Subject: [PATCH 26/50] updates --- store/multistore/store.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 577dee0f495b..427687c29319 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -53,7 +53,6 @@ var _ MultiStore = (*Store)(nil) type Store struct { logger log.Logger - commitHeader CommitHeader initialVersion uint64 // ss reflects the state storage backend @@ -65,6 +64,9 @@ type Store struct { // removalMap reflects module stores marked for removal removalMap map[types.StoreKey]struct{} + // commitHeader reflects the header used when committing state (note, this isn't required and only used for query purposes) + commitHeader CommitHeader + // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *CommitInfo @@ -265,14 +267,13 @@ func (s *Store) Commit() ([]byte, error) { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } - s.lastCommitInfo = commitInfo - s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() - - // TODO: Commit writes to SS backend asynchronously. if err := s.commitSS(version); err != nil { return nil, fmt.Errorf("failed to commit SS: %w", err) } + s.lastCommitInfo = commitInfo + s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() + return s.lastCommitInfo.Hash(), nil } @@ -292,7 +293,7 @@ func (s *Store) clearSCRemovalMap() (err error) { return err } -// PopStateCache returns all the accumulated writes from all SC stores. Note, +// popStateCache returns all the accumulated writes from all SC stores. Note, // calling popStateCache destroys only the currently accumulated state in each // listener not the state in the store itself. This is a mutating and destructive // operation. @@ -311,6 +312,12 @@ func (rs *Store) popStateCache() []*types.StoreKVPair { return writes } +// commitSS flushes all accumulated writes to the SS backend via a single batch. +// Note, this is a synchronous operation. It returns an error if the batch write +// fails. +// +// TODO: Commit writes to SS backend asynchronously. +// Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 func (s *Store) commitSS(version uint64) error { batch, err := s.ss.NewBatch(version) if err != nil { From 60b3f6210d8c3534e1c1ec1963fb8fca464d3d00 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Sep 2023 11:07:22 -0700 Subject: [PATCH 27/50] updates --- store/multistore/store.go | 30 ++++++------- store/{multistore => types}/commit_info.go | 7 ++- store/types/store.go | 51 ++++++++++++++++++++++ store/types/trace.go | 25 +++++++++++ 4 files changed, 97 insertions(+), 16 deletions(-) rename store/{multistore => types}/commit_info.go (91%) create mode 100644 store/types/store.go create mode 100644 store/types/trace.go diff --git a/store/multistore/store.go b/store/multistore/store.go index 427687c29319..c20bdc082273 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -68,7 +68,7 @@ type Store struct { commitHeader CommitHeader // lastCommitInfo reflects the last version/hash that has been committed - lastCommitInfo *CommitInfo + lastCommitInfo *types.CommitInfo // memListeners reflect a mapping of store key to a memory listener, which is used to flush writes to SS memListeners map[types.StoreKey]*types.MemoryListener @@ -113,7 +113,7 @@ func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) e s.scStores[storeKey] = sc // Mount memory listener for the store key so we can flush accumulated writes - // to SS upon Commit. + // to the SS backend upon Commit. if _, ok := s.memListeners[storeKey]; !ok { s.memListeners[storeKey] = types.NewMemoryListener() } @@ -124,7 +124,7 @@ func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) e // LastCommitID returns a CommitID based off of the latest internal CommitInfo. // If an internal CommitInfo is not set, a new one will be returned with only the // latest version set, which is based off of the SS view. -func (s *Store) LastCommitID() (CommitID, error) { +func (s *Store) LastCommitID() (types.CommitID, error) { if s.lastCommitInfo != nil { return s.lastCommitInfo.CommitID(), nil } @@ -136,18 +136,18 @@ func (s *Store) LastCommitID() (CommitID, error) { // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 latestVersion, err := s.ss.GetLatestVersion() if err != nil { - return CommitID{}, err + return types.CommitID{}, err } // ensure integrity of latest version across all SC stores for sk, sc := range s.scStores { scVersion := sc.GetLatestVersion() if scVersion != latestVersion { - return CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) + return types.CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) } } - return CommitID{Version: latestVersion}, nil + return types.CommitID{Version: latestVersion}, nil } // GetLatestVersion returns the latest version based on the latest internal @@ -206,13 +206,13 @@ func (s *Store) loadVersion(v uint64, upgrades any) (err error) { } func (s *Store) WorkingHash() []byte { - storeInfos := make([]StoreInfo, 0, len(s.scStores)) + storeInfos := make([]types.StoreInfo, 0, len(s.scStores)) for sk, sc := range s.scStores { if _, ok := s.removalMap[sk]; !ok { - storeInfos = append(storeInfos, StoreInfo{ + storeInfos = append(storeInfos, types.StoreInfo{ Name: sk.Name(), - CommitID: CommitID{ + CommitID: types.CommitID{ Hash: sc.WorkingHash(), }, }) @@ -223,7 +223,7 @@ func (s *Store) WorkingHash() []byte { return storeInfos[i].Name < storeInfos[j].Name }) - return CommitInfo{StoreInfos: storeInfos}.Hash() + return types.CommitInfo{StoreInfos: storeInfos}.Hash() } func (s *Store) SetCommitHeader(h CommitHeader) { @@ -343,8 +343,8 @@ func (s *Store) commitSS(version uint64) error { // commitSCStores commits each SC store individually and returns a CommitInfo // representing commitment of all the SC stores. Note, commitment is NOT atomic. // An error is returned if any SC store fails to commit. -func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { - storeInfos := make([]StoreInfo, 0, len(s.scStores)) +func (s *Store) commitSCStores(version uint64) (*types.CommitInfo, error) { + storeInfos := make([]types.StoreInfo, 0, len(s.scStores)) for sk, sc := range s.scStores { // TODO: Handle and support SC store last CommitID to handle the case where @@ -366,9 +366,9 @@ func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { return nil, fmt.Errorf("failed to commit SC store %s: %w", sk, err) } - storeInfos = append(storeInfos, StoreInfo{ + storeInfos = append(storeInfos, types.StoreInfo{ Name: sk.Name(), - CommitID: CommitID{ + CommitID: types.CommitID{ Version: version, Hash: commitBz, }, @@ -379,7 +379,7 @@ func (s *Store) commitSCStores(version uint64) (*CommitInfo, error) { return strings.Compare(storeInfos[i].Name, storeInfos[j].Name) < 0 }) - return &CommitInfo{ + return &types.CommitInfo{ Version: version, StoreInfos: storeInfos, }, nil diff --git a/store/multistore/commit_info.go b/store/types/commit_info.go similarity index 91% rename from store/multistore/commit_info.go rename to store/types/commit_info.go index 1e5900e2bdd3..3f229a8f9486 100644 --- a/store/multistore/commit_info.go +++ b/store/types/commit_info.go @@ -1,6 +1,7 @@ -package multistore +package types import ( + "fmt" "time" "cosmossdk.io/store/v2/internal/maps" @@ -67,3 +68,7 @@ func (m *CommitInfo) GetVersion() uint64 { } return 0 } + +func (cid CommitID) String() string { + return fmt.Sprintf("CommitID{%v:%X}", cid.Hash, cid.Version) +} diff --git a/store/types/store.go b/store/types/store.go new file mode 100644 index 000000000000..6667b1e2b8e9 --- /dev/null +++ b/store/types/store.go @@ -0,0 +1,51 @@ +package types + +import "io" + +// StoreType defines a type of KVStore. +type StoreType int + +// KVStore defines the core storage primitive for modules to read and write state. +type KVStore interface { + // GetStoreType returns the concrete store type. + GetStoreType() StoreType + + // Get returns a value for a given key from the store. + Get(key []byte) []byte + + // Has checks if a key exists. + Has(key []byte) bool + + // Set sets a key/value entry to the store. + Set(key, value []byte) + + // Delete deletes the key from the store. + Delete(key []byte) + + CacheWrapper + + // TODO: Iterator. +} + +// CacheWrapper defines an interface for creating a CacheWrap from a KVStore. +type CacheWrapper interface { + CacheWrap() CacheWrap + + // CacheWrapWithTrace branches a store with tracing enabled. + CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap +} + +// CacheWrap defines an interface for branching a KVStore's state, allowing writes +// to be cached and flushed to the underlying store or discarded completed. Reads +// should be checked against a cache before querying the underlying store upon a +// cache miss. A CacheWrap store allows for nested branching. +type CacheWrap interface { + // Write flushes writes to the underlying store. + Write() + + // CacheWrap recursively wraps. + CacheWrap() CacheWrap + + // CacheWrapWithTrace recursively wraps with tracing enabled. + CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap +} diff --git a/store/types/trace.go b/store/types/trace.go new file mode 100644 index 000000000000..e51eba501c36 --- /dev/null +++ b/store/types/trace.go @@ -0,0 +1,25 @@ +package types + +import "golang.org/x/exp/maps" + +// TraceContext contains KVStore context data. It will be written with every +// trace operation. +type TraceContext map[string]interface{} + +// Clone creates a shallow clone of a TraceContext. +func (tc TraceContext) Clone() TraceContext { + return maps.Clone(tc) +} + +// Merge merges the receiver TraceContext with the provided TraceContext argument. +func (tc TraceContext) Merge(newTc TraceContext) TraceContext { + if tc == nil { + tc = TraceContext{} + } + + for k, v := range newTc { + tc[k] = v + } + + return tc +} From 68829532271e34292daf10c9c53fb456f682e43d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Sep 2023 11:15:30 -0700 Subject: [PATCH 28/50] updates --- store/types/store.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/store/types/store.go b/store/types/store.go index 6667b1e2b8e9..f26df187b6cd 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -1,6 +1,10 @@ package types -import "io" +import ( + "io" + + "cosmossdk.io/store/v2" +) // StoreType defines a type of KVStore. type StoreType int @@ -24,7 +28,19 @@ type KVStore interface { CacheWrapper - // TODO: Iterator. + // Iterator creates a new Iterator over the domain [start, end). Note: + // + // - Start must be less than end + // - The iterator must be closed by caller + // - To iterate over entire domain, use store.Iterator(nil, nil) + // + // CONTRACT: No writes may happen within a domain while an iterator exists over + // it, with the exception of a branched/cached KVStore. + Iterator(start, end []byte) store.Iterator + + // ReverseIterator creates a new reverse Iterator over the domain [start, end). + // It has the some properties and contracts as Iterator. + ReverseIterator(start, end []byte) store.Iterator } // CacheWrapper defines an interface for creating a CacheWrap from a KVStore. From c5d8d270171b3f819b4f6399d052857cb97b7617 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Sep 2023 12:25:11 -0700 Subject: [PATCH 29/50] updates --- store/types/store.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/store/types/store.go b/store/types/store.go index f26df187b6cd..efa84c99f4ca 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -43,25 +43,31 @@ type KVStore interface { ReverseIterator(start, end []byte) store.Iterator } -// CacheWrapper defines an interface for creating a CacheWrap from a KVStore. -type CacheWrapper interface { - CacheWrap() CacheWrap +// CacheKVStore defines an interface for a branched a KVStore. It extends KVStore +// by allowing dirty entries to be flushed to the underlying KVStore or discarded +// altogether. A CachedKVStore can itself be branched, allowing for nested branching +// where writes are flushed up the branched stack. +type CacheKVStore interface { + KVStore - // CacheWrapWithTrace branches a store with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap -} - -// CacheWrap defines an interface for branching a KVStore's state, allowing writes -// to be cached and flushed to the underlying store or discarded completed. Reads -// should be checked against a cache before querying the underlying store upon a -// cache miss. A CacheWrap store allows for nested branching. -type CacheWrap interface { // Write flushes writes to the underlying store. Write() // CacheWrap recursively wraps. - CacheWrap() CacheWrap + CacheWrap() CacheKVStore // CacheWrapWithTrace recursively wraps with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap + CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheKVStore +} + +// CacheWrapper defines an interface for a branching a KVStore's state, allowing +// writes to be cached and flushed to the underlying store or discarded altogether. +// Reads should be performed against a "branched" state, allowing dirty entries +// to be cached and read from. If an entry is not found in the branched state, it +// will fallthrough to the underlying KVStore. +type CacheWrapper interface { + CacheWrap() CacheKVStore + + // CacheWrapWithTrace branches a store with tracing enabled. + CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheKVStore } From d6a9ef898c0d724a4e27c677622a9fe15220e815 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 8 Sep 2023 14:11:27 -0700 Subject: [PATCH 30/50] updates --- store/multistore/store.go | 44 ++++---------------------------------- store/types/commit_info.go | 8 +++++++ store/types/store.go | 29 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index c20bdc082273..b600e4efec36 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -2,10 +2,8 @@ package multistore import ( "fmt" - "io" "sort" "strings" - "time" "cosmossdk.io/log" "cosmossdk.io/store/v2" @@ -15,41 +13,7 @@ import ( ics23 "github.com/cosmos/ics23/go" ) -type ( - // MultiStore defines an abstraction layer containing a State Storage (SS) engine - // and one or more State Commitment (SC) engines. - // - // TODO: - // - Move relevant types to the 'core' package. - MultiStore interface { - GetSCStore(storeKey types.StoreKey) *commitment.Database - MountSCStore(storeKey types.StoreKey, sc *commitment.Database) error - GetProof(storeKey types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) - LoadVersion(version uint64) error - LoadLatestVersion() error - GetLatestVersion() (uint64, error) - WorkingHash() []byte - Commit() ([]byte, error) - SetCommitHeader(h CommitHeader) - - // TODO: - // - // - Tracing - // - Branching - // - Queries - // - // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 - - io.Closer - } - - CommitHeader interface { - GetTime() time.Time - GetHeight() uint64 - } -) - -var _ MultiStore = (*Store)(nil) +var _ types.MultiStore = (*Store)(nil) type Store struct { logger log.Logger @@ -65,7 +29,7 @@ type Store struct { removalMap map[types.StoreKey]struct{} // commitHeader reflects the header used when committing state (note, this isn't required and only used for query purposes) - commitHeader CommitHeader + commitHeader types.CommitHeader // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *types.CommitInfo @@ -74,7 +38,7 @@ type Store struct { memListeners map[types.StoreKey]*types.MemoryListener } -func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (MultiStore, error) { +func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (types.MultiStore, error) { return &Store{ logger: logger.With("module", "multi_store"), initialVersion: initVersion, @@ -226,7 +190,7 @@ func (s *Store) WorkingHash() []byte { return types.CommitInfo{StoreInfos: storeInfos}.Hash() } -func (s *Store) SetCommitHeader(h CommitHeader) { +func (s *Store) SetCommitHeader(h types.CommitHeader) { s.commitHeader = h } diff --git a/store/types/commit_info.go b/store/types/commit_info.go index 3f229a8f9486..ac317ce2ac9e 100644 --- a/store/types/commit_info.go +++ b/store/types/commit_info.go @@ -8,6 +8,14 @@ import ( ) type ( + // CommitHeader defines the interface for a block header that can be provided + // to a MultiStore upon Commit. This should be optional and used to facilitate + // time-based queries only. + CommitHeader interface { + GetTime() time.Time + GetHeight() uint64 + } + // CommitInfo defines commit information used by the multi-store when committing // a version/height. CommitInfo struct { diff --git a/store/types/store.go b/store/types/store.go index efa84c99f4ca..57e392a4eeb0 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -4,11 +4,40 @@ import ( "io" "cosmossdk.io/store/v2" + "cosmossdk.io/store/v2/commitment" + ics23 "github.com/cosmos/ics23/go" ) // StoreType defines a type of KVStore. type StoreType int +// MultiStore defines an abstraction layer containing a State Storage (SS) engine +// and one or more State Commitment (SC) engines. +// +// TODO: +// - Move relevant types to the 'core' package. +type MultiStore interface { + GetSCStore(storeKey StoreKey) *commitment.Database + MountSCStore(storeKey StoreKey, sc *commitment.Database) error + GetProof(storeKey StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) + LoadVersion(version uint64) error + LoadLatestVersion() error + GetLatestVersion() (uint64, error) + WorkingHash() []byte + Commit() ([]byte, error) + SetCommitHeader(h CommitHeader) + + // TODO: + // + // - Tracing + // - Branching + // - Queries + // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 + + io.Closer +} + // KVStore defines the core storage primitive for modules to read and write state. type KVStore interface { // GetStoreType returns the concrete store type. From 940e062bb316b33f5c78ca16d421b330f80d5105 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 10 Sep 2023 11:28:34 -0700 Subject: [PATCH 31/50] updates --- store/multistore/store.go | 224 ++++++++++++++------------------------ store/types/store.go | 12 +- 2 files changed, 87 insertions(+), 149 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index b600e4efec36..4cd9b7f59401 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -3,7 +3,6 @@ package multistore import ( "fmt" "sort" - "strings" "cosmossdk.io/log" "cosmossdk.io/store/v2" @@ -13,8 +12,14 @@ import ( ics23 "github.com/cosmos/ics23/go" ) +const defaultStoreKey = "default" + var _ types.MultiStore = (*Store)(nil) +// Store defines the SDK's default MultiStore implementation. It contains a single +// State Storage (SS) backend and a single State Commitment (SC) backend. Note, +// this means all store keys are ignored and commitments exist in a single commitment +// tree. type Store struct { logger log.Logger initialVersion uint64 @@ -22,11 +27,8 @@ type Store struct { // ss reflects the state storage backend ss store.VersionedDatabase - // scStores reflect a mapping of store key to state commitment backend (i.e. a backend per module) - scStores map[types.StoreKey]*commitment.Database - - // removalMap reflects module stores marked for removal - removalMap map[types.StoreKey]struct{} + // ss reflects the state commitment (SC) backend + sc *commitment.Database // commitHeader reflects the header used when committing state (note, this isn't required and only used for query purposes) commitHeader types.CommitHeader @@ -34,17 +36,21 @@ type Store struct { // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *types.CommitInfo - // memListeners reflect a mapping of store key to a memory listener, which is used to flush writes to SS - memListeners map[types.StoreKey]*types.MemoryListener + // memListener reflects a mapping of store key to a memory listener, which is used to flush writes to SS + memListener *types.MemoryListener } -func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (types.MultiStore, error) { +func New( + logger log.Logger, + initVersion uint64, + ss store.VersionedDatabase, + sc *commitment.Database, +) (types.MultiStore, error) { return &Store{ logger: logger.With("module", "multi_store"), initialVersion: initVersion, ss: ss, - scStores: make(map[types.StoreKey]*commitment.Database), - removalMap: make(map[types.StoreKey]struct{}), + sc: sc, }, nil } @@ -52,37 +58,34 @@ func New(logger log.Logger, initVersion uint64, ss store.VersionedDatabase) (typ // idempotent and should only be called once. func (s *Store) Close() (err error) { err = errors.Join(err, s.ss.Close()) - for _, sc := range s.scStores { - err = errors.Join(err, sc.Close()) - } + err = errors.Join(err, s.sc.Close()) s.ss = nil - s.scStores = nil + s.sc = nil s.lastCommitInfo = nil s.commitHeader = nil - s.removalMap = nil return err } -// MountSCStore mounts a state commitment (SC) store to the multi-store. It will -// also create a new MemoryListener entry for the store key if one has not -// already been created. An error is returned if the SC store is already mounted. -func (s *Store) MountSCStore(storeKey types.StoreKey, sc *commitment.Database) error { - s.logger.Debug("mounting store", "store_key", storeKey.String()) - if _, ok := s.scStores[storeKey]; ok { - return fmt.Errorf("SC store with key %s already mounted", storeKey) - } +// MountSCStore performs a no-op as a SC backend must be provided at initialization. +func (s *Store) MountSCStore(_ types.StoreKey, _ *commitment.Database) error { + return errors.New("cannot mount SC store; SC must be provided on initialization") +} - s.scStores[storeKey] = sc +// GetSCStore returns the store's state commitment (SC) backend. Note, the store +// key is ignored as there exists only a single SC tree. +func (s *Store) GetSCStore(_ types.StoreKey) *commitment.Database { + return s.sc +} - // Mount memory listener for the store key so we can flush accumulated writes - // to the SS backend upon Commit. - if _, ok := s.memListeners[storeKey]; !ok { - s.memListeners[storeKey] = types.NewMemoryListener() +func (s *Store) LoadLatestVersion() error { + lv, err := s.GetLatestVersion() + if err != nil { + return err } - return nil + return s.loadVersion(lv, nil) } // LastCommitID returns a CommitID based off of the latest internal CommitInfo. @@ -103,12 +106,10 @@ func (s *Store) LastCommitID() (types.CommitID, error) { return types.CommitID{}, err } - // ensure integrity of latest version across all SC stores - for sk, sc := range s.scStores { - scVersion := sc.GetLatestVersion() - if scVersion != latestVersion { - return types.CommitID{}, fmt.Errorf("unexpected version for %s; got: %d, expected: %d", sk, scVersion, latestVersion) - } + // ensure integrity of latest version against SC + scVersion := s.sc.GetLatestVersion() + if scVersion != latestVersion { + return types.CommitID{}, fmt.Errorf("SC and SS version mismatch; got: %d, expected: %d", scVersion, latestVersion) } return types.CommitID{Version: latestVersion}, nil @@ -126,39 +127,21 @@ func (s *Store) GetLatestVersion() (uint64, error) { return lastCommitID.Version, nil } -func (s *Store) GetProof(storeKey types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) { - sc, ok := s.scStores[storeKey] - if !ok { - return nil, fmt.Errorf("SC store with key %s not mounted", storeKey) - } - - return sc.GetProof(version, key) -} - -func (s *Store) GetSCStore(storeKey types.StoreKey) *commitment.Database { - return s.scStores[storeKey] -} - -func (s *Store) LoadLatestVersion() error { - lv, err := s.GetLatestVersion() - if err != nil { - return err - } - - return s.loadVersion(lv, nil) +// GetProof delegates the GetProof to the store's underlying SC backend. +func (s *Store) GetProof(_ types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) { + return s.sc.GetProof(version, key) } +// LoadVersion loads a specific version returning an error upon failure. func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } -func (s *Store) loadVersion(v uint64, upgrades any) (err error) { +func (s *Store) loadVersion(v uint64, upgrades any) error { s.logger.Debug("loading version", "version", v) - for sk, sc := range s.scStores { - if loadErr := sc.LoadVersion(v); loadErr != nil { - err = errors.Join(err, fmt.Errorf("failed to load version %d for %s: %w", v, sk, loadErr)) - } + if err := s.sc.LoadVersion(v); err != nil { + return fmt.Errorf("failed to load SS version %d: %w", v, err) } // TODO: Complete this method to handle upgrades. See legacy RMS loadVersion() @@ -166,27 +149,19 @@ func (s *Store) loadVersion(v uint64, upgrades any) (err error) { // // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 - return err + return nil } func (s *Store) WorkingHash() []byte { - storeInfos := make([]types.StoreInfo, 0, len(s.scStores)) - - for sk, sc := range s.scStores { - if _, ok := s.removalMap[sk]; !ok { - storeInfos = append(storeInfos, types.StoreInfo{ - Name: sk.Name(), - CommitID: types.CommitID{ - Hash: sc.WorkingHash(), - }, - }) - } + storeInfos := []types.StoreInfo{ + { + Name: defaultStoreKey, + CommitID: types.CommitID{ + Hash: s.sc.WorkingHash(), + }, + }, } - sort.SliceStable(storeInfos, func(i, j int) bool { - return storeInfos[i].Name < storeInfos[j].Name - }) - return types.CommitInfo{StoreInfos: storeInfos}.Hash() } @@ -220,17 +195,13 @@ func (s *Store) Commit() ([]byte, error) { s.logger.Debug("commit header and version mismatch", "header_height", s.commitHeader.GetHeight(), "version", version) } - // remove and close all SC stores marked for removal - if err := s.clearSCRemovalMap(); err != nil { - return nil, fmt.Errorf("failed to clear SC removal map: %w", err) - } - - // commit writes to all SC stores - commitInfo, err := s.commitSCStores(version) + // commit SC + commitInfo, err := s.commitSC(version) if err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } + // commit SS if err := s.commitSS(version); err != nil { return nil, fmt.Errorf("failed to commit SS: %w", err) } @@ -241,22 +212,6 @@ func (s *Store) Commit() ([]byte, error) { return s.lastCommitInfo.Hash(), nil } -func (s *Store) clearSCRemovalMap() (err error) { - for sk := range s.removalMap { - sc, ok := s.scStores[sk] - if ok { - if ce := sc.Close(); ce != nil { - err = errors.Join(err, ce) - } - - delete(s.scStores, sk) - } - } - - s.removalMap = make(map[types.StoreKey]struct{}) - return err -} - // popStateCache returns all the accumulated writes from all SC stores. Note, // calling popStateCache destroys only the currently accumulated state in each // listener not the state in the store itself. This is a mutating and destructive @@ -276,6 +231,30 @@ func (rs *Store) popStateCache() []*types.StoreKVPair { return writes } +// commitSC commits the SC store and returns a CommitInfo representing commitment +// of the underlying SC backend tree. An error is returned if commitment fails. +func (s *Store) commitSC(version uint64) (*types.CommitInfo, error) { + commitBz, err := s.sc.Commit() + if err != nil { + return nil, fmt.Errorf("failed to commit SC store: %w", err) + } + + storeInfos := []types.StoreInfo{ + { + Name: defaultStoreKey, + CommitID: types.CommitID{ + Version: version, + Hash: commitBz, + }, + }, + } + + return &types.CommitInfo{ + Version: version, + StoreInfos: storeInfos, + }, nil +} + // commitSS flushes all accumulated writes to the SS backend via a single batch. // Note, this is a synchronous operation. It returns an error if the batch write // fails. @@ -303,48 +282,3 @@ func (s *Store) commitSS(version uint64) error { return batch.Write() } - -// commitSCStores commits each SC store individually and returns a CommitInfo -// representing commitment of all the SC stores. Note, commitment is NOT atomic. -// An error is returned if any SC store fails to commit. -func (s *Store) commitSCStores(version uint64) (*types.CommitInfo, error) { - storeInfos := make([]types.StoreInfo, 0, len(s.scStores)) - - for sk, sc := range s.scStores { - // TODO: Handle and support SC store last CommitID to handle the case where - // a Commit is interrupted and a SC store could have a version that is ahead: - // - // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 - // scLastCommitID := sc.LastCommitID() - - // var commitID CommitID - // if scLastCommitID.Version >= version { - // scLastCommitID.Version = version - // commitID = scLastCommitID - // } else { - // commitID = store.Commit() - // } - - commitBz, err := sc.Commit() - if err != nil { - return nil, fmt.Errorf("failed to commit SC store %s: %w", sk, err) - } - - storeInfos = append(storeInfos, types.StoreInfo{ - Name: sk.Name(), - CommitID: types.CommitID{ - Version: version, - Hash: commitBz, - }, - }) - } - - sort.SliceStable(storeInfos, func(i, j int) bool { - return strings.Compare(storeInfos[i].Name, storeInfos[j].Name) < 0 - }) - - return &types.CommitInfo{ - Version: version, - StoreInfos: storeInfos, - }, nil -} diff --git a/store/types/store.go b/store/types/store.go index 57e392a4eeb0..dad8f26ce4e4 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -8,24 +8,28 @@ import ( ics23 "github.com/cosmos/ics23/go" ) +// TODO: Move relevant types to the 'core' package. + // StoreType defines a type of KVStore. type StoreType int // MultiStore defines an abstraction layer containing a State Storage (SS) engine // and one or more State Commitment (SC) engines. -// -// TODO: -// - Move relevant types to the 'core' package. type MultiStore interface { GetSCStore(storeKey StoreKey) *commitment.Database MountSCStore(storeKey StoreKey, sc *commitment.Database) error + GetKVStore(storeKey StoreKey) KVStore + Branch() MultiStore + GetProof(storeKey StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) + LoadVersion(version uint64) error LoadLatestVersion() error GetLatestVersion() (uint64, error) + WorkingHash() []byte - Commit() ([]byte, error) SetCommitHeader(h CommitHeader) + Commit() ([]byte, error) // TODO: // From d148d71c2ffba6826c8393641408cddc066316f9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 10 Sep 2023 11:31:17 -0700 Subject: [PATCH 32/50] updates --- store/multistore/store.go | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 4cd9b7f59401..498720877144 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -2,7 +2,6 @@ package multistore import ( "fmt" - "sort" "cosmossdk.io/log" "cosmossdk.io/store/v2" @@ -36,7 +35,7 @@ type Store struct { // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *types.CommitInfo - // memListener reflects a mapping of store key to a memory listener, which is used to flush writes to SS + // memListener is used to track and flush writes to the SS backend memListener *types.MemoryListener } @@ -64,6 +63,7 @@ func (s *Store) Close() (err error) { s.sc = nil s.lastCommitInfo = nil s.commitHeader = nil + s.memListener = nil return err } @@ -212,25 +212,6 @@ func (s *Store) Commit() ([]byte, error) { return s.lastCommitInfo.Hash(), nil } -// popStateCache returns all the accumulated writes from all SC stores. Note, -// calling popStateCache destroys only the currently accumulated state in each -// listener not the state in the store itself. This is a mutating and destructive -// operation. -func (rs *Store) popStateCache() []*types.StoreKVPair { - var writes []*types.StoreKVPair - for _, ml := range rs.memListeners { - if ml != nil { - writes = append(writes, ml.PopStateCache()...) - } - } - - sort.SliceStable(writes, func(i, j int) bool { - return writes[i].StoreKey < writes[j].StoreKey - }) - - return writes -} - // commitSC commits the SC store and returns a CommitInfo representing commitment // of the underlying SC backend tree. An error is returned if commitment fails. func (s *Store) commitSC(version uint64) (*types.CommitInfo, error) { @@ -267,8 +248,7 @@ func (s *Store) commitSS(version uint64) error { return err } - writes := s.popStateCache() - for _, skv := range writes { + for _, skv := range s.memListener.PopStateCache() { if skv.Delete { if err := batch.Delete(skv.StoreKey, skv.Key); err != nil { return err From a1a11056dd8d7ac3f2b74f192c9dc7fac40f8192 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 10 Sep 2023 11:32:10 -0700 Subject: [PATCH 33/50] updates --- store/multistore/store.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index 498720877144..889cf58e5e8e 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -137,6 +137,14 @@ func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } +func (s *Store) GetKVStore(_ types.StoreKey) types.KVStore { + panic("not implemented!") +} + +func (s *Store) Branch() types.MultiStore { + panic("not implemented!") +} + func (s *Store) loadVersion(v uint64, upgrades any) error { s.logger.Debug("loading version", "version", v) From d1bf22143bb8290cc1af70862668abee385d12cb Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 10 Sep 2023 11:35:48 -0700 Subject: [PATCH 34/50] updates --- store/multistore/store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 889cf58e5e8e..20806a340a11 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -221,7 +221,8 @@ func (s *Store) Commit() ([]byte, error) { } // commitSC commits the SC store and returns a CommitInfo representing commitment -// of the underlying SC backend tree. An error is returned if commitment fails. +// of the underlying SC backend tree. Since there is only a single SC backing tree, +// all SC commits are atomic. An error is returned if commitment fails. func (s *Store) commitSC(version uint64) (*types.CommitInfo, error) { commitBz, err := s.sc.Commit() if err != nil { From e292c87de301fb5e58da0019b019d89ce0b8a582 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 10 Sep 2023 11:36:56 -0700 Subject: [PATCH 35/50] updates --- store/multistore/store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/store/multistore/store.go b/store/multistore/store.go index 20806a340a11..5ad55ec853b8 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -11,6 +11,9 @@ import ( ics23 "github.com/cosmos/ics23/go" ) +// defaultStoreKey defines the default store key used for the single SC backend. +// Note, however, this store key is essentially irrelevant as it's not exposed +// to the user and it only needed to fulfill usage of StoreInfo during Commit. const defaultStoreKey = "default" var _ types.MultiStore = (*Store)(nil) From c64d3f37ad50719d194becc339a764e58a4f28ad Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 11 Sep 2023 10:03:57 -0700 Subject: [PATCH 36/50] updates --- store/multistore/store.go | 8 ++--- store/types/memory_listener.go | 4 +-- store/types/store.go | 34 ++++++++++---------- store/types/store_key.go | 59 ---------------------------------- 4 files changed, 23 insertions(+), 82 deletions(-) delete mode 100644 store/types/store_key.go diff --git a/store/multistore/store.go b/store/multistore/store.go index 5ad55ec853b8..7ea08d8f3055 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -72,13 +72,13 @@ func (s *Store) Close() (err error) { } // MountSCStore performs a no-op as a SC backend must be provided at initialization. -func (s *Store) MountSCStore(_ types.StoreKey, _ *commitment.Database) error { +func (s *Store) MountSCStore(_ string, _ *commitment.Database) error { return errors.New("cannot mount SC store; SC must be provided on initialization") } // GetSCStore returns the store's state commitment (SC) backend. Note, the store // key is ignored as there exists only a single SC tree. -func (s *Store) GetSCStore(_ types.StoreKey) *commitment.Database { +func (s *Store) GetSCStore(_ string) *commitment.Database { return s.sc } @@ -131,7 +131,7 @@ func (s *Store) GetLatestVersion() (uint64, error) { } // GetProof delegates the GetProof to the store's underlying SC backend. -func (s *Store) GetProof(_ types.StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) { +func (s *Store) GetProof(_ string, version uint64, key []byte) (*ics23.CommitmentProof, error) { return s.sc.GetProof(version, key) } @@ -140,7 +140,7 @@ func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } -func (s *Store) GetKVStore(_ types.StoreKey) types.KVStore { +func (s *Store) GetKVStore(_ string) types.KVStore { panic("not implemented!") } diff --git a/store/types/memory_listener.go b/store/types/memory_listener.go index 32ed1fd1ba00..aba42be1e316 100644 --- a/store/types/memory_listener.go +++ b/store/types/memory_listener.go @@ -10,9 +10,9 @@ func NewMemoryListener() *MemoryListener { } // OnWrite records a state write in memory. -func (fl *MemoryListener) OnWrite(storeKey StoreKey, key, value []byte, delete bool) { +func (fl *MemoryListener) OnWrite(storeKey string, key, value []byte, delete bool) { fl.stateCache = append(fl.stateCache, &StoreKVPair{ - StoreKey: storeKey.Name(), + StoreKey: storeKey, Delete: delete, Key: key, Value: value, diff --git a/store/types/store.go b/store/types/store.go index dad8f26ce4e4..18b9b29ae6ef 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -16,12 +16,12 @@ type StoreType int // MultiStore defines an abstraction layer containing a State Storage (SS) engine // and one or more State Commitment (SC) engines. type MultiStore interface { - GetSCStore(storeKey StoreKey) *commitment.Database - MountSCStore(storeKey StoreKey, sc *commitment.Database) error - GetKVStore(storeKey StoreKey) KVStore + GetSCStore(storeKey string) *commitment.Database + MountSCStore(storeKey string, sc *commitment.Database) error + GetKVStore(storeKey string) KVStore Branch() MultiStore - GetProof(storeKey StoreKey, version uint64, key []byte) (*ics23.CommitmentProof, error) + GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) LoadVersion(version uint64) error LoadLatestVersion() error @@ -59,7 +59,7 @@ type KVStore interface { // Delete deletes the key from the store. Delete(key []byte) - CacheWrapper + BranchWrapper // Iterator creates a new Iterator over the domain [start, end). Note: // @@ -76,31 +76,31 @@ type KVStore interface { ReverseIterator(start, end []byte) store.Iterator } -// CacheKVStore defines an interface for a branched a KVStore. It extends KVStore +// BranchedKVStore defines an interface for a branched a KVStore. It extends KVStore // by allowing dirty entries to be flushed to the underlying KVStore or discarded -// altogether. A CachedKVStore can itself be branched, allowing for nested branching +// altogether. A BranchedKVStore can itself be branched, allowing for nested branching // where writes are flushed up the branched stack. -type CacheKVStore interface { +type BranchedKVStore interface { KVStore // Write flushes writes to the underlying store. Write() - // CacheWrap recursively wraps. - CacheWrap() CacheKVStore + // Branch recursively wraps. + Branch() BranchedKVStore - // CacheWrapWithTrace recursively wraps with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheKVStore + // BranchWithTrace recursively wraps with tracing enabled. + BranchWithTrace(w io.Writer, tc TraceContext) BranchedKVStore } -// CacheWrapper defines an interface for a branching a KVStore's state, allowing +// BranchWrapper defines an interface for a branching a KVStore's state, allowing // writes to be cached and flushed to the underlying store or discarded altogether. // Reads should be performed against a "branched" state, allowing dirty entries // to be cached and read from. If an entry is not found in the branched state, it // will fallthrough to the underlying KVStore. -type CacheWrapper interface { - CacheWrap() CacheKVStore +type BranchWrapper interface { + Branch() BranchedKVStore - // CacheWrapWithTrace branches a store with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheKVStore + // BranchWithTrace branches a store with tracing enabled. + BranchWithTrace(w io.Writer, tc TraceContext) BranchedKVStore } diff --git a/store/types/store_key.go b/store/types/store_key.go deleted file mode 100644 index 9eaf4ae2190a..000000000000 --- a/store/types/store_key.go +++ /dev/null @@ -1,59 +0,0 @@ -package types - -import ( - "fmt" - "sort" - "strings" -) - -// StoreKey defines an interface for types that provide store keys. -type StoreKey interface { - Name() string - String() string -} - -// KVStoreKey is used for providing permissioned access to module stores. -type KVStoreKey struct { - name string -} - -func NewKVStoreKey(name string) *KVStoreKey { - if name == "" { - panic("empty key name not allowed") - } - - return &KVStoreKey{ - name: name, - } -} - -func NewKVStoreKeys(names ...string) map[string]*KVStoreKey { - assertNoCommonPrefix(names) - keys := make(map[string]*KVStoreKey, len(names)) - for _, n := range names { - keys[n] = NewKVStoreKey(n) - } - - return keys -} - -func (key *KVStoreKey) Name() string { - return key.name -} - -func (key *KVStoreKey) String() string { - return fmt.Sprintf("KVStoreKey{%p, %s}", key, key.name) -} - -func assertNoCommonPrefix(keys []string) { - sorted := make([]string, len(keys)) - - copy(sorted, keys) - sort.Strings(sorted) - - for i := 1; i < len(sorted); i++ { - if strings.HasPrefix(sorted[i], sorted[i-1]) { - panic(fmt.Errorf("potential key collision between KVStores: %s, %s", sorted[i], sorted[i-1])) - } - } -} From 6225e3e9bc3755f4b013fda800d63a479d2e29a3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 11 Sep 2023 10:04:32 -0700 Subject: [PATCH 37/50] updates --- store/multistore/store.go | 6 +++--- store/types/store.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/store/multistore/store.go b/store/multistore/store.go index 7ea08d8f3055..d0ce298039f3 100644 --- a/store/multistore/store.go +++ b/store/multistore/store.go @@ -16,7 +16,7 @@ import ( // to the user and it only needed to fulfill usage of StoreInfo during Commit. const defaultStoreKey = "default" -var _ types.MultiStore = (*Store)(nil) +var _ types.RootStore = (*Store)(nil) // Store defines the SDK's default MultiStore implementation. It contains a single // State Storage (SS) backend and a single State Commitment (SC) backend. Note, @@ -47,7 +47,7 @@ func New( initVersion uint64, ss store.VersionedDatabase, sc *commitment.Database, -) (types.MultiStore, error) { +) (types.RootStore, error) { return &Store{ logger: logger.With("module", "multi_store"), initialVersion: initVersion, @@ -144,7 +144,7 @@ func (s *Store) GetKVStore(_ string) types.KVStore { panic("not implemented!") } -func (s *Store) Branch() types.MultiStore { +func (s *Store) Branch() types.RootStore { panic("not implemented!") } diff --git a/store/types/store.go b/store/types/store.go index 18b9b29ae6ef..874a8f246bd2 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -13,13 +13,13 @@ import ( // StoreType defines a type of KVStore. type StoreType int -// MultiStore defines an abstraction layer containing a State Storage (SS) engine +// RootStore defines an abstraction layer containing a State Storage (SS) engine // and one or more State Commitment (SC) engines. -type MultiStore interface { +type RootStore interface { GetSCStore(storeKey string) *commitment.Database MountSCStore(storeKey string, sc *commitment.Database) error GetKVStore(storeKey string) KVStore - Branch() MultiStore + Branch() RootStore GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) From 5588971096a1a88934ea4bd26b63afc098404cd7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 11 Sep 2023 10:05:05 -0700 Subject: [PATCH 38/50] updates --- store/{multistore => root}/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename store/{multistore => root}/store.go (99%) diff --git a/store/multistore/store.go b/store/root/store.go similarity index 99% rename from store/multistore/store.go rename to store/root/store.go index d0ce298039f3..4651e58e4276 100644 --- a/store/multistore/store.go +++ b/store/root/store.go @@ -1,4 +1,4 @@ -package multistore +package root import ( "fmt" From 000dca896d54c8605112d0cd5d0ede2526f97116 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 11 Sep 2023 10:07:34 -0700 Subject: [PATCH 39/50] updates --- store/root/store.go | 2 +- store/types/store.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/store/root/store.go b/store/root/store.go index 4651e58e4276..ad63f69c5bd8 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -18,7 +18,7 @@ const defaultStoreKey = "default" var _ types.RootStore = (*Store)(nil) -// Store defines the SDK's default MultiStore implementation. It contains a single +// Store defines the SDK's default RootStore implementation. It contains a single // State Storage (SS) backend and a single State Commitment (SC) backend. Note, // this means all store keys are ignored and commitments exist in a single commitment // tree. diff --git a/store/types/store.go b/store/types/store.go index 874a8f246bd2..19592f440049 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -34,7 +34,6 @@ type RootStore interface { // TODO: // // - Tracing - // - Branching // - Queries // // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 From 5b65da5406d9c5e079a6e6666dd6a9237c3a149a Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 12 Sep 2023 11:26:47 -0700 Subject: [PATCH 40/50] updates --- store/branch/store.go | 106 +++++++++++++++++++++++++++ store/change_set.go | 39 ++++++++++ store/{types => }/commit_info.go | 2 +- store/commitment/db.go | 10 +-- store/commitment/db_test.go | 30 ++++---- store/commitment/iavl/tree.go | 11 ++- store/commitment/types/batch.go | 33 --------- store/go.mod | 2 +- store/go.sum | 19 +++++ store/root/store.go | 83 +++++++++++---------- store/{types => }/store.go | 29 +++++--- store/{types => }/trace.go | 2 +- store/{commitment/types => }/tree.go | 4 +- store/types/kv_pair.go | 10 --- store/types/memory_listener.go | 27 ------- 15 files changed, 260 insertions(+), 147 deletions(-) create mode 100644 store/branch/store.go create mode 100644 store/change_set.go rename store/{types => }/commit_info.go (99%) delete mode 100644 store/commitment/types/batch.go rename store/{types => }/store.go (82%) rename store/{types => }/trace.go (97%) rename store/{commitment/types => }/tree.go (88%) delete mode 100644 store/types/kv_pair.go delete mode 100644 store/types/memory_listener.go diff --git a/store/branch/store.go b/store/branch/store.go new file mode 100644 index 000000000000..a312fdffa69e --- /dev/null +++ b/store/branch/store.go @@ -0,0 +1,106 @@ +package branch + +import ( + "io" + "slices" + + "cosmossdk.io/store/v2" + "golang.org/x/exp/maps" +) + +var ( + _ store.KVStore = (*Store)(nil) + _ store.BranchedKVStore = (*Store)(nil) +) + +// Store implements both a KVStore and BranchedKVStore interfaces. It is used to +// accumulate writes that can be later committed to backing SS and SC engines or +// discarded altogether. If a read is not found through an uncommitted write, it +// will be delegated to the SS backend. +type Store struct { + // storage reflects backing storage for reads that are not found in uncommitted volatile state + // + // XXX/TODO: We use a SC backend here instead of SS since not all SS backends + // may support reverse iteration (which is needed for state machine logic). + storage store.Tree + + // storeKey reflects the store key used for the store + storeKey string + + // parent reflects a parent store if branched (it may be nil) + parent store.KVStore + + // changeSet reflects the uncommitted writes to the store + // + // Note, this field might be removed depending on how the branching fields + // below are defined and used. + changeSet map[string]store.KVPair + + // TODO: Fields for branching functionality. These fields should most likely + // reflect what currently exists in cachekv.Store. +} + +func New(storeKey string, sc store.Tree) store.KVStore { + return &Store{ + storage: sc, + storeKey: storeKey, + changeSet: make(map[string]store.KVPair), + } +} + +func (s *Store) GetStoreType() store.StoreType { + return store.StoreTypeBranch +} + +// GetChangeSet returns the uncommitted writes to the store, ordered by key. +func (s *Store) GetChangeSet() *store.ChangeSet { + keys := maps.Keys(s.changeSet) + slices.Sort(keys) + + pairs := make([]store.KVPair, len(keys)) + for i, key := range keys { + pairs[i] = s.changeSet[key] + } + + return store.NewChangeSet(pairs...) +} + +func (s *Store) Reset() { + clear(s.changeSet) +} + +func (s *Store) Branch() store.BranchedKVStore { + panic("not implemented!") +} + +func (s *Store) BranchWithTrace(w io.Writer, tc store.TraceContext) store.BranchedKVStore { + panic("not implemented!") +} + +func (s *Store) Iterator(start, end []byte) store.Iterator { + panic("not implemented!") +} + +func (s *Store) ReverseIterator(start, end []byte) store.Iterator { + panic("not implemented!") +} + +func (s *Store) Get(key []byte) []byte { + panic("not implemented!") +} + +func (s *Store) Has(key []byte) bool { + panic("not implemented!") +} + +func (s *Store) Set(key, value []byte) { + panic("not implemented!") +} + +func (s *Store) Delete(key []byte) { + panic("not implemented!") +} + +func (s *Store) Write() { + panic("not implemented!") +} diff --git a/store/change_set.go b/store/change_set.go new file mode 100644 index 000000000000..b666cb0ac0cc --- /dev/null +++ b/store/change_set.go @@ -0,0 +1,39 @@ +package store + +// KVPair defines a key-value pair with additional metadata that is used to +// track writes. Deletion can be denoted by a nil value or explicitly by the +// Delete field. +type KVPair struct { + Key []byte + Value []byte + StoreKey string // optional +} + +// ChangeSet defines a set of KVPair entries. +type ChangeSet struct { + Pairs []KVPair +} + +func NewChangeSet(pairs ...KVPair) *ChangeSet { + return &ChangeSet{ + Pairs: pairs, + } +} + +// Size returns the number of key-value pairs in the batch. +func (cs *ChangeSet) Size() int { + return len(cs.Pairs) +} + +// Add adds a key-value pair to the ChangeSet. +func (cs *ChangeSet) Add(key, value []byte) { + cs.Pairs = append(cs.Pairs, KVPair{ + Key: key, + Value: value, + }) +} + +// AddKVPair adds a KVPair to the ChangeSet. +func (cs *ChangeSet) AddKVPair(pair KVPair) { + cs.Pairs = append(cs.Pairs, pair) +} diff --git a/store/types/commit_info.go b/store/commit_info.go similarity index 99% rename from store/types/commit_info.go rename to store/commit_info.go index ac317ce2ac9e..103118ece02f 100644 --- a/store/types/commit_info.go +++ b/store/commit_info.go @@ -1,4 +1,4 @@ -package types +package store import ( "fmt" diff --git a/store/commitment/db.go b/store/commitment/db.go index d46ba7f225d2..df58933d45bc 100644 --- a/store/commitment/db.go +++ b/store/commitment/db.go @@ -5,7 +5,7 @@ import ( ics23 "github.com/cosmos/ics23/go" - "cosmossdk.io/store/v2/commitment/types" + "cosmossdk.io/store/v2" ) // Database represents a state commitment store. It is designed to securely store @@ -13,22 +13,22 @@ import ( // Each module creates its own instance of Database for managing its specific state. type Database struct { mu sync.Mutex - tree types.Tree + tree store.Tree } // NewDatabase creates a new Database instance. -func NewDatabase(tree types.Tree) *Database { +func NewDatabase(tree store.Tree) *Database { return &Database{ tree: tree, } } // WriteBatch writes a batch of key-value pairs to the database. -func (db *Database) WriteBatch(batch *types.Batch) error { +func (db *Database) WriteBatch(cs *store.ChangeSet) error { db.mu.Lock() defer db.mu.Unlock() - return db.tree.WriteBatch(batch) + return db.tree.WriteBatch(cs) } // WorkingHash returns the working hash of the database. diff --git a/store/commitment/db_test.go b/store/commitment/db_test.go index 2a2d60030018..7924f1e2533b 100644 --- a/store/commitment/db_test.go +++ b/store/commitment/db_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/log" + "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment/iavl" - "cosmossdk.io/store/v2/commitment/types" ) -func generateTree(treeType string) types.Tree { +func generateTree(treeType string) store.Tree { if treeType == "iavl" { cfg := iavl.DefaultConfig() db := dbm.NewMemDB() @@ -28,16 +28,16 @@ func TestIavlTree(t *testing.T) { tree := generateTree("iavl") require.NotNil(t, tree) - intialVersion := tree.GetLatestVersion() - require.Equal(t, uint64(0), intialVersion) + initVersion := tree.GetLatestVersion() + require.Equal(t, uint64(0), initVersion) // write a batch of version 1 - batch1 := types.NewBatch() - batch1.Add([]byte("key1"), []byte("value1")) - batch1.Add([]byte("key2"), []byte("value2")) - batch1.Add([]byte("key3"), []byte("value3")) + cs1 := store.NewChangeSet() + cs1.Add([]byte("key1"), []byte("value1")) + cs1.Add([]byte("key2"), []byte("value2")) + cs1.Add([]byte("key3"), []byte("value3")) - err := tree.WriteBatch(batch1) + err := tree.WriteBatch(cs1) require.NoError(t, err) workingHash := tree.WorkingHash() @@ -52,12 +52,12 @@ func TestIavlTree(t *testing.T) { version1Hash := tree.WorkingHash() // write a batch of version 2 - batch2 := types.NewBatch() - batch2.Add([]byte("key4"), []byte("value4")) - batch2.Add([]byte("key5"), []byte("value5")) - batch2.Add([]byte("key6"), []byte("value6")) - batch2.Add([]byte("key1"), nil) // delete key1 - err = tree.WriteBatch(batch2) + cs2 := store.NewChangeSet() + cs2.Add([]byte("key4"), []byte("value4")) + cs2.Add([]byte("key5"), []byte("value5")) + cs2.Add([]byte("key6"), []byte("value6")) + cs2.Add([]byte("key1"), nil) // delete key1 + err = tree.WriteBatch(cs2) require.NoError(t, err) workingHash = tree.WorkingHash() require.NotNil(t, workingHash) diff --git a/store/commitment/iavl/tree.go b/store/commitment/iavl/tree.go index 4f63caaca7e0..6b89989a84ba 100644 --- a/store/commitment/iavl/tree.go +++ b/store/commitment/iavl/tree.go @@ -3,15 +3,14 @@ package iavl import ( "fmt" + log "cosmossdk.io/log" + "cosmossdk.io/store/v2" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/iavl" ics23 "github.com/cosmos/ics23/go" - - log "cosmossdk.io/log" - commitmenttypes "cosmossdk.io/store/v2/commitment/types" ) -var _ commitmenttypes.Tree = (*IavlTree)(nil) +var _ store.Tree = (*IavlTree)(nil) // IavlTree is a wrapper around iavl.MutableTree. type IavlTree struct { @@ -27,8 +26,8 @@ func NewIavlTree(db dbm.DB, logger log.Logger, cfg *Config) *IavlTree { } // WriteBatch writes a batch of key-value pairs to the database. -func (t *IavlTree) WriteBatch(batch *commitmenttypes.Batch) error { - for _, kv := range batch.Pairs { +func (t *IavlTree) WriteBatch(cs *store.ChangeSet) error { + for _, kv := range cs.Pairs { if kv.Value == nil { _, res, err := t.tree.Remove(kv.Key) if err != nil { diff --git a/store/commitment/types/batch.go b/store/commitment/types/batch.go deleted file mode 100644 index f9a7f79ea68c..000000000000 --- a/store/commitment/types/batch.go +++ /dev/null @@ -1,33 +0,0 @@ -package types - -// KVPair is a key-value pair. It is used to represent a change in a Batch. -// NOTE: The Value can be nil, which means the key is deleted. -type KVPair struct { - Key []byte - Value []byte -} - -// Batch is a change set that can be committed to the database atomically. -type Batch struct { - Pairs []KVPair -} - -// NewBatch creates a new Batch instance. -func NewBatch() *Batch { - return &Batch{ - Pairs: make([]KVPair, 0), - } -} - -// Size returns the number of key-value pairs in the batch. -func (b *Batch) Size() int { - return len(b.Pairs) -} - -// Add adds a key-value pair to the batch. -func (b *Batch) Add(key, value []byte) { - b.Pairs = append(b.Pairs, KVPair{ - Key: key, - Value: value, - }) -} diff --git a/store/go.mod b/store/go.mod index 87d797d739f8..d287484e414f 100644 --- a/store/go.mod +++ b/store/go.mod @@ -1,6 +1,6 @@ module cosmossdk.io/store/v2 -go 1.20 +go 1.21 require ( cosmossdk.io/errors v1.0.0 diff --git a/store/go.sum b/store/go.sum index 4338b4de0f1a..63300e8a49d4 100644 --- a/store/go.sum +++ b/store/go.sum @@ -11,13 +11,16 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= @@ -44,6 +47,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -51,18 +55,22 @@ github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+m github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4= github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -86,6 +94,7 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= +github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -110,6 +119,7 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -128,10 +138,12 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d h1:htwtWgtQo8YS6JFWWi2DNgY0RwSGJ1ruMoxY6CUUclk= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -195,6 +207,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -253,6 +266,7 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -264,6 +278,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= @@ -271,7 +286,9 @@ modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= +modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= +modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v1.24.1 h1:uvJSeCKL/AgzBo2yYIPPTy82v21KgGnizcGYfBHaNuM= modernc.org/libc v1.24.1/go.mod h1:FmfO1RLrU3MHJfyi9eYYmZBfi/R+tqZ6+hQ3yQQUkak= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= @@ -285,6 +302,8 @@ modernc.org/sqlite v1.25.0/go.mod h1:FL3pVXie73rg3Rii6V/u5BoHlSoyeZeIgKZEgHARyCU modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= modernc.org/tcl v1.15.2 h1:C4ybAYCGJw968e+Me18oW55kD/FexcHbqH2xak1ROSY= +modernc.org/tcl v1.15.2/go.mod h1:3+k/ZaEbKrC8ePv8zJWPtBSW0V7Gg9g8rkmhI1Kfs3c= modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg= modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.7.3 h1:zDJf6iHjrnB+WRD88stbXokugjyc0/pB91ri1gO6LZY= +modernc.org/z v1.7.3/go.mod h1:Ipv4tsdxZRbQyLq9Q1M6gdbkxYzdlrciF2Hi/lS7nWE= diff --git a/store/root/store.go b/store/root/store.go index ad63f69c5bd8..72761d91e74d 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -5,8 +5,8 @@ import ( "cosmossdk.io/log" "cosmossdk.io/store/v2" + "cosmossdk.io/store/v2/branch" "cosmossdk.io/store/v2/commitment" - "cosmossdk.io/store/v2/types" "github.com/cockroachdb/errors" ics23 "github.com/cosmos/ics23/go" ) @@ -16,7 +16,7 @@ import ( // to the user and it only needed to fulfill usage of StoreInfo during Commit. const defaultStoreKey = "default" -var _ types.RootStore = (*Store)(nil) +var _ store.RootStore = (*Store)(nil) // Store defines the SDK's default RootStore implementation. It contains a single // State Storage (SS) backend and a single State Commitment (SC) backend. Note, @@ -32,14 +32,15 @@ type Store struct { // ss reflects the state commitment (SC) backend sc *commitment.Database + // rootKVStore reflects the root KVStore that is used to accumulate writes + // and branch off of. + rootKVStore store.KVStore + // commitHeader reflects the header used when committing state (note, this isn't required and only used for query purposes) - commitHeader types.CommitHeader + commitHeader store.CommitHeader // lastCommitInfo reflects the last version/hash that has been committed - lastCommitInfo *types.CommitInfo - - // memListener is used to track and flush writes to the SS backend - memListener *types.MemoryListener + lastCommitInfo *store.CommitInfo } func New( @@ -47,12 +48,13 @@ func New( initVersion uint64, ss store.VersionedDatabase, sc *commitment.Database, -) (types.RootStore, error) { +) (store.RootStore, error) { return &Store{ - logger: logger.With("module", "multi_store"), + logger: logger.With("module", "root_store"), initialVersion: initVersion, ss: ss, sc: sc, + rootKVStore: branch.New(defaultStoreKey, sc), }, nil } @@ -66,19 +68,18 @@ func (s *Store) Close() (err error) { s.sc = nil s.lastCommitInfo = nil s.commitHeader = nil - s.memListener = nil return err } // MountSCStore performs a no-op as a SC backend must be provided at initialization. -func (s *Store) MountSCStore(_ string, _ *commitment.Database) error { +func (s *Store) MountSCStore(_ string, _ store.Tree) error { return errors.New("cannot mount SC store; SC must be provided on initialization") } // GetSCStore returns the store's state commitment (SC) backend. Note, the store // key is ignored as there exists only a single SC tree. -func (s *Store) GetSCStore(_ string) *commitment.Database { +func (s *Store) GetSCStore(_ string) store.Tree { return s.sc } @@ -94,7 +95,7 @@ func (s *Store) LoadLatestVersion() error { // LastCommitID returns a CommitID based off of the latest internal CommitInfo. // If an internal CommitInfo is not set, a new one will be returned with only the // latest version set, which is based off of the SS view. -func (s *Store) LastCommitID() (types.CommitID, error) { +func (s *Store) LastCommitID() (store.CommitID, error) { if s.lastCommitInfo != nil { return s.lastCommitInfo.CommitID(), nil } @@ -106,16 +107,16 @@ func (s *Store) LastCommitID() (types.CommitID, error) { // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 latestVersion, err := s.ss.GetLatestVersion() if err != nil { - return types.CommitID{}, err + return store.CommitID{}, err } // ensure integrity of latest version against SC scVersion := s.sc.GetLatestVersion() if scVersion != latestVersion { - return types.CommitID{}, fmt.Errorf("SC and SS version mismatch; got: %d, expected: %d", scVersion, latestVersion) + return store.CommitID{}, fmt.Errorf("SC and SS version mismatch; got: %d, expected: %d", scVersion, latestVersion) } - return types.CommitID{Version: latestVersion}, nil + return store.CommitID{Version: latestVersion}, nil } // GetLatestVersion returns the latest version based on the latest internal @@ -140,12 +141,12 @@ func (s *Store) LoadVersion(v uint64) (err error) { return s.loadVersion(v, nil) } -func (s *Store) GetKVStore(_ string) types.KVStore { - panic("not implemented!") -} - -func (s *Store) Branch() types.RootStore { - panic("not implemented!") +// GetKVStore returns the store's root KVStore. Any writes to this store without +// branching will be committed to SC and SS upon Commit(). Branching will create +// a branched KVStore that allow writes to be discarded and propagated to the +// root KVStore using Write(). +func (s *Store) GetKVStore(_ string) store.KVStore { + return s.rootKVStore } func (s *Store) loadVersion(v uint64, upgrades any) error { @@ -164,19 +165,19 @@ func (s *Store) loadVersion(v uint64, upgrades any) error { } func (s *Store) WorkingHash() []byte { - storeInfos := []types.StoreInfo{ + storeInfos := []store.StoreInfo{ { Name: defaultStoreKey, - CommitID: types.CommitID{ + CommitID: store.CommitID{ Hash: s.sc.WorkingHash(), }, }, } - return types.CommitInfo{StoreInfos: storeInfos}.Hash() + return store.CommitInfo{StoreInfos: storeInfos}.Hash() } -func (s *Store) SetCommitHeader(h types.CommitHeader) { +func (s *Store) SetCommitHeader(h store.CommitHeader) { s.commitHeader = h } @@ -206,43 +207,51 @@ func (s *Store) Commit() ([]byte, error) { s.logger.Debug("commit header and version mismatch", "header_height", s.commitHeader.GetHeight(), "version", version) } + changeSet := s.rootKVStore.GetChangeSet() + // commit SC - commitInfo, err := s.commitSC(version) + commitInfo, err := s.commitSC(version, changeSet) if err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } // commit SS - if err := s.commitSS(version); err != nil { + if err := s.commitSS(version, changeSet); err != nil { return nil, fmt.Errorf("failed to commit SS: %w", err) } s.lastCommitInfo = commitInfo s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() + s.rootKVStore.Reset() + return s.lastCommitInfo.Hash(), nil } // commitSC commits the SC store and returns a CommitInfo representing commitment // of the underlying SC backend tree. Since there is only a single SC backing tree, // all SC commits are atomic. An error is returned if commitment fails. -func (s *Store) commitSC(version uint64) (*types.CommitInfo, error) { +func (s *Store) commitSC(version uint64, cs *store.ChangeSet) (*store.CommitInfo, error) { + if err := s.sc.WriteBatch(cs); err != nil { + return nil, fmt.Errorf("failed to write batch to SC store: %w", err) + } + commitBz, err := s.sc.Commit() if err != nil { return nil, fmt.Errorf("failed to commit SC store: %w", err) } - storeInfos := []types.StoreInfo{ + storeInfos := []store.StoreInfo{ { Name: defaultStoreKey, - CommitID: types.CommitID{ + CommitID: store.CommitID{ Version: version, Hash: commitBz, }, }, } - return &types.CommitInfo{ + return &store.CommitInfo{ Version: version, StoreInfos: storeInfos, }, nil @@ -254,19 +263,19 @@ func (s *Store) commitSC(version uint64) (*types.CommitInfo, error) { // // TODO: Commit writes to SS backend asynchronously. // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 -func (s *Store) commitSS(version uint64) error { +func (s *Store) commitSS(version uint64, cs *store.ChangeSet) error { batch, err := s.ss.NewBatch(version) if err != nil { return err } - for _, skv := range s.memListener.PopStateCache() { - if skv.Delete { - if err := batch.Delete(skv.StoreKey, skv.Key); err != nil { + for _, pair := range cs.Pairs { + if pair.Value == nil { + if err := batch.Delete(pair.StoreKey, pair.Key); err != nil { return err } } else { - if err := batch.Set(skv.StoreKey, skv.Key, skv.Value); err != nil { + if err := batch.Set(pair.StoreKey, pair.Key, pair.Value); err != nil { return err } } diff --git a/store/types/store.go b/store/store.go similarity index 82% rename from store/types/store.go rename to store/store.go index 19592f440049..489bd6df8f39 100644 --- a/store/types/store.go +++ b/store/store.go @@ -1,10 +1,8 @@ -package types +package store import ( "io" - "cosmossdk.io/store/v2" - "cosmossdk.io/store/v2/commitment" ics23 "github.com/cosmos/ics23/go" ) @@ -13,13 +11,17 @@ import ( // StoreType defines a type of KVStore. type StoreType int +// Sentinel store types. +const ( + StoreTypeBranch StoreType = iota +) + // RootStore defines an abstraction layer containing a State Storage (SS) engine // and one or more State Commitment (SC) engines. type RootStore interface { - GetSCStore(storeKey string) *commitment.Database - MountSCStore(storeKey string, sc *commitment.Database) error + GetSCStore(storeKey string) Tree + MountSCStore(storeKey string, sc Tree) error GetKVStore(storeKey string) KVStore - Branch() RootStore GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) @@ -34,6 +36,7 @@ type RootStore interface { // TODO: // // - Tracing + // - Branching // - Queries // // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 @@ -58,6 +61,9 @@ type KVStore interface { // Delete deletes the key from the store. Delete(key []byte) + // Reset resets the store, which is implementation dependent. + Reset() + BranchWrapper // Iterator creates a new Iterator over the domain [start, end). Note: @@ -68,11 +74,11 @@ type KVStore interface { // // CONTRACT: No writes may happen within a domain while an iterator exists over // it, with the exception of a branched/cached KVStore. - Iterator(start, end []byte) store.Iterator + Iterator(start, end []byte) Iterator // ReverseIterator creates a new reverse Iterator over the domain [start, end). // It has the some properties and contracts as Iterator. - ReverseIterator(start, end []byte) store.Iterator + ReverseIterator(start, end []byte) Iterator } // BranchedKVStore defines an interface for a branched a KVStore. It extends KVStore @@ -96,10 +102,15 @@ type BranchedKVStore interface { // writes to be cached and flushed to the underlying store or discarded altogether. // Reads should be performed against a "branched" state, allowing dirty entries // to be cached and read from. If an entry is not found in the branched state, it -// will fallthrough to the underlying KVStore. +// will fallthrough to the underlying store. type BranchWrapper interface { Branch() BranchedKVStore // BranchWithTrace branches a store with tracing enabled. BranchWithTrace(w io.Writer, tc TraceContext) BranchedKVStore + + // GetChangeSet returns the ChangeSet, if any, for the branched state. This + // should contain all writes that are marked to be flushed and committed during + // Commit(). + GetChangeSet() *ChangeSet } diff --git a/store/types/trace.go b/store/trace.go similarity index 97% rename from store/types/trace.go rename to store/trace.go index e51eba501c36..3d711a11c181 100644 --- a/store/types/trace.go +++ b/store/trace.go @@ -1,4 +1,4 @@ -package types +package store import "golang.org/x/exp/maps" diff --git a/store/commitment/types/tree.go b/store/tree.go similarity index 88% rename from store/commitment/types/tree.go rename to store/tree.go index 61e9c1d8aaa9..aac4756b824a 100644 --- a/store/commitment/types/tree.go +++ b/store/tree.go @@ -1,4 +1,4 @@ -package types +package store import ( ics23 "github.com/cosmos/ics23/go" @@ -6,7 +6,7 @@ import ( // Tree is an interface for a commitment layer to support multiple backends. type Tree interface { - WriteBatch(batch *Batch) error + WriteBatch(cs *ChangeSet) error WorkingHash() []byte GetLatestVersion() uint64 LoadVersion(targetVersion uint64) error diff --git a/store/types/kv_pair.go b/store/types/kv_pair.go deleted file mode 100644 index 7b34355f0afc..000000000000 --- a/store/types/kv_pair.go +++ /dev/null @@ -1,10 +0,0 @@ -package types - -// StoreKVPair defines a key-value pair with additional metadata that is used -// to track writes to an underlying SC store. -type StoreKVPair struct { - StoreKey string - Delete bool - Key []byte - Value []byte -} diff --git a/store/types/memory_listener.go b/store/types/memory_listener.go deleted file mode 100644 index aba42be1e316..000000000000 --- a/store/types/memory_listener.go +++ /dev/null @@ -1,27 +0,0 @@ -package types - -// MemoryListener listens to the state writes and accumulate the records in memory. -type MemoryListener struct { - stateCache []*StoreKVPair -} - -func NewMemoryListener() *MemoryListener { - return &MemoryListener{} -} - -// OnWrite records a state write in memory. -func (fl *MemoryListener) OnWrite(storeKey string, key, value []byte, delete bool) { - fl.stateCache = append(fl.stateCache, &StoreKVPair{ - StoreKey: storeKey, - Delete: delete, - Key: key, - Value: value, - }) -} - -// PopStateCache returns the current state caches and set to nil. -func (fl *MemoryListener) PopStateCache() []*StoreKVPair { - res := fl.stateCache - fl.stateCache = nil - return res -} From 403f0098694c7830a22a0b981304f43e393b0f20 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 12 Sep 2023 11:49:12 -0700 Subject: [PATCH 41/50] lint --- store/branch/store.go | 3 ++- store/commitment/iavl/tree.go | 5 +++-- store/internal/maps/maps.go | 5 +++-- store/internal/proofs/create.go | 3 ++- store/root/store.go | 5 +++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/store/branch/store.go b/store/branch/store.go index a312fdffa69e..f5df1df383f3 100644 --- a/store/branch/store.go +++ b/store/branch/store.go @@ -2,10 +2,11 @@ package branch import ( "io" + + "golang.org/x/exp/maps" "slices" "cosmossdk.io/store/v2" - "golang.org/x/exp/maps" ) var ( diff --git a/store/commitment/iavl/tree.go b/store/commitment/iavl/tree.go index 6b89989a84ba..6edddd199cfa 100644 --- a/store/commitment/iavl/tree.go +++ b/store/commitment/iavl/tree.go @@ -3,11 +3,12 @@ package iavl import ( "fmt" - log "cosmossdk.io/log" - "cosmossdk.io/store/v2" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/iavl" ics23 "github.com/cosmos/ics23/go" + + log "cosmossdk.io/log" + "cosmossdk.io/store/v2" ) var _ store.Tree = (*IavlTree)(nil) diff --git a/store/internal/maps/maps.go b/store/internal/maps/maps.go index 0b016e664eb9..1d8d8f1a0767 100644 --- a/store/internal/maps/maps.go +++ b/store/internal/maps/maps.go @@ -3,11 +3,12 @@ package maps import ( "encoding/binary" - "cosmossdk.io/store/v2/internal/kv" - "cosmossdk.io/store/v2/internal/tree" "github.com/cometbft/cometbft/crypto/merkle" "github.com/cometbft/cometbft/crypto/tmhash" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + + "cosmossdk.io/store/v2/internal/kv" + "cosmossdk.io/store/v2/internal/tree" ) // merkleMap defines a merkle-ized tree from a map. Leave values are treated as diff --git a/store/internal/proofs/create.go b/store/internal/proofs/create.go index 805b5257a4de..47e55e97854e 100644 --- a/store/internal/proofs/create.go +++ b/store/internal/proofs/create.go @@ -4,8 +4,9 @@ import ( "errors" "sort" - "cosmossdk.io/store/v2/internal/maps" ics23 "github.com/cosmos/ics23/go" + + "cosmossdk.io/store/v2/internal/maps" ) var ( diff --git a/store/root/store.go b/store/root/store.go index 72761d91e74d..5b7e90803b96 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -3,12 +3,13 @@ package root import ( "fmt" + "github.com/cockroachdb/errors" + ics23 "github.com/cosmos/ics23/go" + "cosmossdk.io/log" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/branch" "cosmossdk.io/store/v2/commitment" - "github.com/cockroachdb/errors" - ics23 "github.com/cosmos/ics23/go" ) // defaultStoreKey defines the default store key used for the single SC backend. From d459bb10f242c9155ef1b72a5d2e3e0acb127bde Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 12 Sep 2023 16:15:45 -0700 Subject: [PATCH 42/50] updates --- store/root/store.go | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/store/root/store.go b/store/root/store.go index 5b7e90803b96..32571f984188 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -27,11 +27,11 @@ type Store struct { logger log.Logger initialVersion uint64 - // ss reflects the state storage backend - ss store.VersionedDatabase + // stateStore reflects the state storage backend + stateStore store.VersionedDatabase - // ss reflects the state commitment (SC) backend - sc *commitment.Database + // stateCommitment reflects the state commitment (SC) backend + stateCommitment *commitment.Database // rootKVStore reflects the root KVStore that is used to accumulate writes // and branch off of. @@ -51,22 +51,22 @@ func New( sc *commitment.Database, ) (store.RootStore, error) { return &Store{ - logger: logger.With("module", "root_store"), - initialVersion: initVersion, - ss: ss, - sc: sc, - rootKVStore: branch.New(defaultStoreKey, sc), + logger: logger.With("module", "root_store"), + initialVersion: initVersion, + stateStore: ss, + stateCommitment: sc, + rootKVStore: branch.New(defaultStoreKey, sc), }, nil } // Close closes the store and resets all internal fields. Note, Close() is NOT // idempotent and should only be called once. func (s *Store) Close() (err error) { - err = errors.Join(err, s.ss.Close()) - err = errors.Join(err, s.sc.Close()) + err = errors.Join(err, s.stateStore.Close()) + err = errors.Join(err, s.stateCommitment.Close()) - s.ss = nil - s.sc = nil + s.stateStore = nil + s.stateCommitment = nil s.lastCommitInfo = nil s.commitHeader = nil @@ -81,7 +81,7 @@ func (s *Store) MountSCStore(_ string, _ store.Tree) error { // GetSCStore returns the store's state commitment (SC) backend. Note, the store // key is ignored as there exists only a single SC tree. func (s *Store) GetSCStore(_ string) store.Tree { - return s.sc + return s.stateCommitment } func (s *Store) LoadLatestVersion() error { @@ -106,13 +106,13 @@ func (s *Store) LastCommitID() (store.CommitID, error) { // in SS might not be the latest version in the SC stores. // // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 - latestVersion, err := s.ss.GetLatestVersion() + latestVersion, err := s.stateStore.GetLatestVersion() if err != nil { return store.CommitID{}, err } // ensure integrity of latest version against SC - scVersion := s.sc.GetLatestVersion() + scVersion := s.stateCommitment.GetLatestVersion() if scVersion != latestVersion { return store.CommitID{}, fmt.Errorf("SC and SS version mismatch; got: %d, expected: %d", scVersion, latestVersion) } @@ -134,7 +134,7 @@ func (s *Store) GetLatestVersion() (uint64, error) { // GetProof delegates the GetProof to the store's underlying SC backend. func (s *Store) GetProof(_ string, version uint64, key []byte) (*ics23.CommitmentProof, error) { - return s.sc.GetProof(version, key) + return s.stateCommitment.GetProof(version, key) } // LoadVersion loads a specific version returning an error upon failure. @@ -153,7 +153,7 @@ func (s *Store) GetKVStore(_ string) store.KVStore { func (s *Store) loadVersion(v uint64, upgrades any) error { s.logger.Debug("loading version", "version", v) - if err := s.sc.LoadVersion(v); err != nil { + if err := s.stateCommitment.LoadVersion(v); err != nil { return fmt.Errorf("failed to load SS version %d: %w", v, err) } @@ -170,7 +170,7 @@ func (s *Store) WorkingHash() []byte { { Name: defaultStoreKey, CommitID: store.CommitID{ - Hash: s.sc.WorkingHash(), + Hash: s.stateCommitment.WorkingHash(), }, }, } @@ -233,11 +233,11 @@ func (s *Store) Commit() ([]byte, error) { // of the underlying SC backend tree. Since there is only a single SC backing tree, // all SC commits are atomic. An error is returned if commitment fails. func (s *Store) commitSC(version uint64, cs *store.ChangeSet) (*store.CommitInfo, error) { - if err := s.sc.WriteBatch(cs); err != nil { + if err := s.stateCommitment.WriteBatch(cs); err != nil { return nil, fmt.Errorf("failed to write batch to SC store: %w", err) } - commitBz, err := s.sc.Commit() + commitBz, err := s.stateCommitment.Commit() if err != nil { return nil, fmt.Errorf("failed to commit SC store: %w", err) } @@ -265,7 +265,7 @@ func (s *Store) commitSC(version uint64, cs *store.ChangeSet) (*store.CommitInfo // TODO: Commit writes to SS backend asynchronously. // Ref: https://github.com/cosmos/cosmos-sdk/issues/17314 func (s *Store) commitSS(version uint64, cs *store.ChangeSet) error { - batch, err := s.ss.NewBatch(version) + batch, err := s.stateStore.NewBatch(version) if err != nil { return err } From b830c938e37d6ae36a8b15d57de3b93fba9d523a Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 14 Sep 2023 10:24:25 -0700 Subject: [PATCH 43/50] updates --- store/go.mod | 5 +- store/go.sum | 194 ++------------------------------------------------- 2 files changed, 6 insertions(+), 193 deletions(-) diff --git a/store/go.mod b/store/go.mod index bf31eacf3b40..a34be26f2d1e 100644 --- a/store/go.mod +++ b/store/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/log v1.2.0 cosmossdk.io/math v1.1.2 - github.com/cockroachdb/errors v1.8.1 + github.com/cockroachdb/errors v1.11.1 github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c github.com/cometbft/cometbft v0.38.0-rc3 github.com/cosmos/cosmos-db v1.0.0 @@ -26,13 +26,12 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect - github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emicklei/dot v1.4.2 // indirect - github.com/go-errors/errors v1.4.2 // indirect + github.com/getsentry/sentry-go v0.18.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect diff --git a/store/go.sum b/store/go.sum index 2b182c18152c..583dd66e442a 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1,22 +1,11 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -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-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= -github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= @@ -25,38 +14,25 @@ github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipus github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM= -github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= -github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c h1:aDetJlMe4qJxWAwu+/bzTs2/b1EW9ecVyawpRD7N/tE= github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c/go.mod h1:EDjiaAXc0FXiRmxDzcu1wIEJ093ohHMUWxrI6iku0XA= -github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/cometbft/cometbft v0.38.0-rc3 h1:Ly3eVPWoFu0y68PmZwLljucPdEBtfigZtqm+OV1W6dE= github.com/cometbft/cometbft v0.38.0-rc3/go.mod h1:5Jz0Z8YsHSf0ZaAqGvi/ifioSdVFPtEGrm8Y9T/993k= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= @@ -66,7 +42,6 @@ github.com/cosmos/iavl v1.0.0-rc.1 h1:5+73BEWW1gZOIUJKlk/1fpD4lOqqeFBA8KuV+NpkCp github.com/cosmos/iavl v1.0.0-rc.1/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -75,22 +50,10 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -98,33 +61,17 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= +github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -137,94 +84,44 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= -github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= -github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= -github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= github.com/linxGnu/grocksdb v1.8.0/go.mod h1:09CeBborffXhXdNpEcOeZrLKEnRtrZFEpFdPNI9Zjjg= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= -github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -232,7 +129,6 @@ github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:Fa github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= @@ -243,21 +139,18 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d h1:htwtWgtQo8YS6JFWWi2DNgY0RwSGJ1ruMoxY6CUUclk= github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= @@ -273,78 +166,33 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -353,30 +201,21 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -394,21 +233,12 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -420,18 +250,8 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 h1:lv6/DhyiFFGsmzxbsUUTOkN29II+zeWHxvT8Lpdxsv0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -445,13 +265,9 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -463,8 +279,6 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= From 6b3fc00db485440e742113eea0b772319b4cb40f Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 14 Sep 2023 10:25:33 -0700 Subject: [PATCH 44/50] updates --- store/branch/store.go | 13 +++++-------- store/root/store.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/store/branch/store.go b/store/branch/store.go index f5df1df383f3..b89c9d0b3652 100644 --- a/store/branch/store.go +++ b/store/branch/store.go @@ -2,9 +2,9 @@ package branch import ( "io" + "slices" "golang.org/x/exp/maps" - "slices" "cosmossdk.io/store/v2" ) @@ -19,11 +19,8 @@ var ( // discarded altogether. If a read is not found through an uncommitted write, it // will be delegated to the SS backend. type Store struct { - // storage reflects backing storage for reads that are not found in uncommitted volatile state - // - // XXX/TODO: We use a SC backend here instead of SS since not all SS backends - // may support reverse iteration (which is needed for state machine logic). - storage store.Tree + // storage reflects backing storage (SS) for reads that are not found in uncommitted volatile state + storage store.VersionedDatabase // storeKey reflects the store key used for the store storeKey string @@ -41,9 +38,9 @@ type Store struct { // reflect what currently exists in cachekv.Store. } -func New(storeKey string, sc store.Tree) store.KVStore { +func New(storeKey string, ss store.VersionedDatabase) store.KVStore { return &Store{ - storage: sc, + storage: ss, storeKey: storeKey, changeSet: make(map[string]store.KVPair), } diff --git a/store/root/store.go b/store/root/store.go index 32571f984188..462af9c8295f 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -55,7 +55,7 @@ func New( initialVersion: initVersion, stateStore: ss, stateCommitment: sc, - rootKVStore: branch.New(defaultStoreKey, sc), + rootKVStore: branch.New(defaultStoreKey, ss), }, nil } From ecb5e915726bae683d0af98ae90da2c081f9c25e Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 14 Sep 2023 10:56:30 -0700 Subject: [PATCH 45/50] updates --- store/root/store.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/store/root/store.go b/store/root/store.go index 462af9c8295f..cfdd6cfff026 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -210,17 +210,17 @@ func (s *Store) Commit() ([]byte, error) { changeSet := s.rootKVStore.GetChangeSet() + // commit SS + if err := s.commitSS(version, changeSet); err != nil { + return nil, fmt.Errorf("failed to commit SS: %w", err) + } + // commit SC commitInfo, err := s.commitSC(version, changeSet) if err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } - // commit SS - if err := s.commitSS(version, changeSet); err != nil { - return nil, fmt.Errorf("failed to commit SS: %w", err) - } - s.lastCommitInfo = commitInfo s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() From aa335e7d3d9bd65e1ad2ceac015f6098befd3436 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Sep 2023 11:08:15 -0700 Subject: [PATCH 46/50] updates --- store/branch/store.go | 2 +- store/storage/storage_test_suite.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/store/branch/store.go b/store/branch/store.go index b89c9d0b3652..31c44800f4b8 100644 --- a/store/branch/store.go +++ b/store/branch/store.go @@ -2,9 +2,9 @@ package branch import ( "io" - "slices" "golang.org/x/exp/maps" + "slices" "cosmossdk.io/store/v2" ) diff --git a/store/storage/storage_test_suite.go b/store/storage/storage_test_suite.go index 2c054948cbc1..83427935d5b3 100644 --- a/store/storage/storage_test_suite.go +++ b/store/storage/storage_test_suite.go @@ -2,9 +2,9 @@ package storage import ( "fmt" - "slices" "github.com/stretchr/testify/suite" + "slices" "cosmossdk.io/store/v2" ) From 01320e22d6e44c6870ce1ce85575664784f85e5d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Sep 2023 14:31:53 -0700 Subject: [PATCH 47/50] lint++ --- store/branch/store.go | 4 ++-- store/storage/storage_test_suite.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/store/branch/store.go b/store/branch/store.go index 31c44800f4b8..db4d3272755a 100644 --- a/store/branch/store.go +++ b/store/branch/store.go @@ -2,9 +2,9 @@ package branch import ( "io" + "slices" "golang.org/x/exp/maps" - "slices" "cosmossdk.io/store/v2" ) @@ -26,7 +26,7 @@ type Store struct { storeKey string // parent reflects a parent store if branched (it may be nil) - parent store.KVStore + // parent store.KVStore // changeSet reflects the uncommitted writes to the store // diff --git a/store/storage/storage_test_suite.go b/store/storage/storage_test_suite.go index 83427935d5b3..2c054948cbc1 100644 --- a/store/storage/storage_test_suite.go +++ b/store/storage/storage_test_suite.go @@ -2,9 +2,9 @@ package storage import ( "fmt" + "slices" "github.com/stretchr/testify/suite" - "slices" "cosmossdk.io/store/v2" ) From b6ab2fb93fe5cc10526cb9f8a32cdb9c6662318c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Sep 2023 15:22:30 -0700 Subject: [PATCH 48/50] updates --- store/storage/pebbledb/db.go | 4 ++-- store/storage/pebbledb/iterator.go | 6 +++--- store/storage/util/bytes.go | 13 ------------- 3 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 store/storage/util/bytes.go diff --git a/store/storage/pebbledb/db.go b/store/storage/pebbledb/db.go index 95a1864bab02..ea14f44f0a82 100644 --- a/store/storage/pebbledb/db.go +++ b/store/storage/pebbledb/db.go @@ -6,11 +6,11 @@ import ( "errors" "fmt" "math" + "slices" "github.com/cockroachdb/pebble" "cosmossdk.io/store/v2" - "cosmossdk.io/store/v2/storage/util" ) const ( @@ -238,5 +238,5 @@ func getMVCCSlice(db *pebble.DB, storeKey string, key []byte, version uint64) ([ return nil, fmt.Errorf("key version too large: %d", keyVersion) } - return util.CopyBytes(itr.Value()), nil + return slices.Clone(itr.Value()), nil } diff --git a/store/storage/pebbledb/iterator.go b/store/storage/pebbledb/iterator.go index af64a537916c..9c301bf84089 100644 --- a/store/storage/pebbledb/iterator.go +++ b/store/storage/pebbledb/iterator.go @@ -3,11 +3,11 @@ package pebbledb import ( "bytes" "fmt" + "slices" "github.com/cockroachdb/pebble" "cosmossdk.io/store/v2" - "cosmossdk.io/store/v2/storage/util" ) var _ store.Iterator = (*iterator)(nil) @@ -78,7 +78,7 @@ func (itr *iterator) Key() []byte { panic(fmt.Sprintf("invalid PebbleDB MVCC key: %s", itr.source.Key())) } - keyCopy := util.CopyBytes(key) + keyCopy := slices.Clone(key) return keyCopy[len(itr.prefix):] } @@ -92,7 +92,7 @@ func (itr *iterator) Value() []byte { panic(fmt.Sprintf("invalid PebbleDB MVCC value: %s", itr.source.Key())) } - return util.CopyBytes(val) + return slices.Clone(val) } func (itr *iterator) Next() bool { diff --git a/store/storage/util/bytes.go b/store/storage/util/bytes.go deleted file mode 100644 index 4240a170dff0..000000000000 --- a/store/storage/util/bytes.go +++ /dev/null @@ -1,13 +0,0 @@ -package util - -// CopyBytes copies a byte slice. It returns if the argument is . -func CopyBytes(bz []byte) []byte { - if bz == nil { - return nil - } - - ret := make([]byte, len(bz)) - _ = copy(ret, bz) - - return ret -} From 451d994bfb5c10203e15c7c1e1eb1d55f370c338 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 27 Sep 2023 15:24:54 -0700 Subject: [PATCH 49/50] refactor WorkingHash + Commit() --- store/root/store.go | 157 ++++++++++++++++++++++++++++---------------- store/store.go | 2 +- 2 files changed, 101 insertions(+), 58 deletions(-) diff --git a/store/root/store.go b/store/root/store.go index cfdd6cfff026..a4c1bf3fd023 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -1,7 +1,9 @@ package root import ( + "bytes" "fmt" + "slices" "github.com/cockroachdb/errors" ics23 "github.com/cosmos/ics23/go" @@ -42,6 +44,9 @@ type Store struct { // lastCommitInfo reflects the last version/hash that has been committed lastCommitInfo *store.CommitInfo + + // workingHash defines the current (yet to be committed) hash + workingHash []byte } func New( @@ -111,7 +116,7 @@ func (s *Store) LastCommitID() (store.CommitID, error) { return store.CommitID{}, err } - // ensure integrity of latest version against SC + // sanity check: ensure integrity of latest version against SC scVersion := s.stateCommitment.GetLatestVersion() if scVersion != latestVersion { return store.CommitID{}, fmt.Errorf("SC and SS version mismatch; got: %d, expected: %d", scVersion, latestVersion) @@ -165,45 +170,44 @@ func (s *Store) loadVersion(v uint64, upgrades any) error { return nil } -func (s *Store) WorkingHash() []byte { - storeInfos := []store.StoreInfo{ - { - Name: defaultStoreKey, - CommitID: store.CommitID{ - Hash: s.stateCommitment.WorkingHash(), - }, - }, - } - - return store.CommitInfo{StoreInfos: storeInfos}.Hash() -} - func (s *Store) SetCommitHeader(h store.CommitHeader) { s.commitHeader = h } -// Commit commits all state changes to the underlying SS backend and all SC stores. -// Note, writes to the SS backend are retrieved from the SC memory listeners and -// are committed in a single batch synchronously. All writes to each SC are also -// committed synchronously, however, they are NOT atomic. A byte slice is returned -// reflecting the Merkle root hash of all committed SC stores. +// WorkingHash returns the working hash of the root store. Note, WorkingHash() +// should only be called once per block once all writes are complete and prior +// to Commit() being called. +// +// If working hash is nil, then we need to compute and set it on the root store +// by constructing a CommitInfo object, which in turn creates and writes a batch +// of the current changeset to the SC tree. +func (s *Store) WorkingHash() ([]byte, error) { + if s.workingHash == nil { + if err := s.writeSC(); err != nil { + return nil, err + } + + s.workingHash = s.lastCommitInfo.Hash() + } + + return slices.Clone(s.workingHash), nil +} + +// Commit commits all state changes to the underlying SS and SC backends. Note, +// at the time of Commit(), we expect WorkingHash() to have already been called, +// which internally sets the working hash, retrieved by writing a batch of the +// changeset to the SC tree, and CommitInfo on the root store. The changeset is +// retrieved from the rootKVStore and represents the entire set of writes to be +// committed. The same changeset is used to flush writes to the SS backend. +// +// Note, Commit() commits SC and SC synchronously. func (s *Store) Commit() ([]byte, error) { - var previousHeight, version uint64 - if s.lastCommitInfo.GetVersion() == 0 && s.initialVersion > 1 { - // This case means that no commit has been made in the store, we - // start from initialVersion. - version = s.initialVersion - } else { - // This case can means two things: - // - // 1. There was already a previous commit in the store, in which case we - // increment the version from there. - // 2. There was no previous commit, and initial version was not set, in which - // case we start at version 1. - previousHeight = s.lastCommitInfo.GetVersion() - version = previousHeight + 1 + if s.workingHash == nil { + return nil, fmt.Errorf("working hash is nil; must call WorkingHash() before Commit()") } + version := s.lastCommitInfo.Version + if s.commitHeader.GetHeight() != version { s.logger.Debug("commit header and version mismatch", "header_height", s.commitHeader.GetHeight(), "version", version) } @@ -216,46 +220,85 @@ func (s *Store) Commit() ([]byte, error) { } // commit SC - commitInfo, err := s.commitSC(version, changeSet) - if err != nil { + if err := s.commitSC(); err != nil { return nil, fmt.Errorf("failed to commit SC stores: %w", err) } - s.lastCommitInfo = commitInfo - s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() + if s.commitHeader != nil { + s.lastCommitInfo.Timestamp = s.commitHeader.GetTime() + } s.rootKVStore.Reset() + s.workingHash = nil - return s.lastCommitInfo.Hash(), nil + return s.WorkingHash() } -// commitSC commits the SC store and returns a CommitInfo representing commitment -// of the underlying SC backend tree. Since there is only a single SC backing tree, -// all SC commits are atomic. An error is returned if commitment fails. -func (s *Store) commitSC(version uint64, cs *store.ChangeSet) (*store.CommitInfo, error) { - if err := s.stateCommitment.WriteBatch(cs); err != nil { - return nil, fmt.Errorf("failed to write batch to SC store: %w", err) +// writeSC gets the current changeset from the rootKVStore and writes that as a +// batch to the underlying SC tree, which allows us to retrieve the working hash +// of the SC tree. Finally, we construct a *CommitInfo and return the hash. +// Note, this should only be called once per block! +func (s *Store) writeSC() error { + changeSet := s.rootKVStore.GetChangeSet() + + if err := s.stateCommitment.WriteBatch(changeSet); err != nil { + return fmt.Errorf("failed to write batch to SC store: %w", err) } - commitBz, err := s.stateCommitment.Commit() - if err != nil { - return nil, fmt.Errorf("failed to commit SC store: %w", err) + var previousHeight, version uint64 + if s.lastCommitInfo.GetVersion() == 0 && s.initialVersion > 1 { + // This case means that no commit has been made in the store, we + // start from initialVersion. + version = s.initialVersion + } else { + // This case can means two things: + // + // 1. There was already a previous commit in the store, in which case we + // increment the version from there. + // 2. There was no previous commit, and initial version was not set, in which + // case we start at version 1. + previousHeight = s.lastCommitInfo.GetVersion() + version = previousHeight + 1 } - storeInfos := []store.StoreInfo{ - { - Name: defaultStoreKey, - CommitID: store.CommitID{ - Version: version, - Hash: commitBz, + workingHash := s.stateCommitment.WorkingHash() + + s.lastCommitInfo = &store.CommitInfo{ + Version: version, + StoreInfos: []store.StoreInfo{ + { + Name: defaultStoreKey, + CommitID: store.CommitID{ + Version: version, + Hash: workingHash, + }, }, }, } - return &store.CommitInfo{ - Version: version, - StoreInfos: storeInfos, - }, nil + return nil +} + +// commitSC commits the SC store. At this point, a batch of the current changeset +// should have already been written to the SC via WorkingHash(). This method +// solely commits that batch. An error is returned if commit fails or if the +// resulting commit hash is not equivalent to the working hash. +func (s *Store) commitSC() error { + commitBz, err := s.stateCommitment.Commit() + if err != nil { + return fmt.Errorf("failed to commit SC store: %w", err) + } + + workingHash, err := s.WorkingHash() + if err != nil { + return fmt.Errorf("failed to get working hash: %w", err) + } + + if bytes.Equal(commitBz, workingHash) { + return fmt.Errorf("unexpected commit hash; got: %X, expected: %X", commitBz, workingHash) + } + + return nil } // commitSS flushes all accumulated writes to the SS backend via a single batch. diff --git a/store/store.go b/store/store.go index 489bd6df8f39..96f52b5974d1 100644 --- a/store/store.go +++ b/store/store.go @@ -29,7 +29,7 @@ type RootStore interface { LoadLatestVersion() error GetLatestVersion() (uint64, error) - WorkingHash() []byte + WorkingHash() ([]byte, error) SetCommitHeader(h CommitHeader) Commit() ([]byte, error) From 86efa09cb71939569828e3b2a411cc7f54a7aa3c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 28 Sep 2023 09:16:30 -0700 Subject: [PATCH 50/50] updates --- store/root/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/root/store.go b/store/root/store.go index a4c1bf3fd023..526b193c89f1 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -231,7 +231,7 @@ func (s *Store) Commit() ([]byte, error) { s.rootKVStore.Reset() s.workingHash = nil - return s.WorkingHash() + return s.lastCommitInfo.Hash(), nil } // writeSC gets the current changeset from the rootKVStore and writes that as a