Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Table-Store (aka ORM) package - Table and Indexable #9751

Merged
merged 35 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5539498
WIP on adding table/indexable
blushi Jul 8, 2021
10a3bec
Add some tests
blushi Jul 20, 2021
86a5ac6
Add more tests
blushi Jul 22, 2021
580c41b
Add sequence
blushi Jul 22, 2021
d0a77b6
Update testdata
blushi Jul 22, 2021
fc72796
Lint
blushi Jul 22, 2021
71cac77
Merge branch 'master' into marie/9237-table-store-1
blushi Jul 22, 2021
a4a4e09
Add docs
blushi Jul 22, 2021
b6f2d08
Update docs
blushi Jul 22, 2021
ed2a1d2
Use Update instead of Save
blushi Jul 28, 2021
b0a8586
Merge branch 'master' into marie/9237-table-store-1
blushi Jul 28, 2021
30c765b
Move orm to x/group
blushi Aug 11, 2021
5e71573
Add orm
blushi Aug 11, 2021
63168ed
Merge branch 'master' into marie/9237-table-store-1
blushi Aug 11, 2021
482617d
Merge branch 'master' into marie/9237-table-store-1
blushi Sep 2, 2021
09d832a
Merge branch 'master' into marie/9237-table-store-1
blushi Oct 7, 2021
0151b74
Update orm with latest changes
blushi Oct 8, 2021
4d2486a
Mv orm to x/group/internal
blushi Oct 8, 2021
a368554
Update go.mod and fix tests
blushi Oct 8, 2021
ce21252
Update README
blushi Oct 8, 2021
8956be8
Merge branch 'master' into marie/9237-table-store-1
blushi Oct 8, 2021
560662e
Fix tests
blushi Oct 8, 2021
bb495f7
Use [2]byte for table prefix key
blushi Oct 8, 2021
915d734
Update docs
blushi Oct 8, 2021
0ef7f82
Merge branch 'master' into marie/9237-table-store-1
blushi Oct 8, 2021
e3aa3e8
Rm file
blushi Oct 8, 2021
df0c304
Rm file
blushi Oct 8, 2021
661d449
Revert store/README
blushi Oct 8, 2021
b47264d
Register errors in types/errors
blushi Oct 8, 2021
00b97d8
Fix group err
blushi Oct 8, 2021
61cbb3c
Merge branch 'master' into marie/9237-table-store-1
blushi Oct 14, 2021
a8b57d2
Simplify table creation
blushi Oct 21, 2021
7c63cbd
Merge branch 'master' into marie/9237-table-store-1
blushi Oct 21, 2021
87fc7b0
Update x/group/internal/orm/table.go
blushi Oct 21, 2021
d2f9a52
Address review comments
blushi Oct 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions testutil/testdata/table.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package testdata

import "github.com/cosmos/cosmos-sdk/types/errors"

var (
ErrTest = errors.Register("table_testdata", 2, "test")
)

func (g TableModel) ValidateBasic() error {
if g.Name == "" {
return errors.Wrap(ErrTest, "name")
}
return nil
}
255 changes: 231 additions & 24 deletions testutil/testdata/testdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions testutil/testdata/testdata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ message BadMultiSignature {
repeated bytes signatures = 1;
bytes malicious_field = 5;
}

message TableModel {
uint64 id = 1;
string name = 2;
}
21 changes: 21 additions & 0 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const UndefinedCodespace = "undefined"
// mathCodespace is the codespace for all errors defined in math package
const mathCodespace = "math"

// mathCodespace is the codespace for all errors defined in orm package
const ormCodespace = "orm"

var (
// errInternal should never be exposed, but we reserve this code for non-specified errors
errInternal = Register(UndefinedCodespace, 1, "internal")
Expand Down Expand Up @@ -153,6 +156,24 @@ var (

// ErrInvalidDecString defines an error for an invalid decimal string
ErrInvalidDecString = Register(mathCodespace, 41, "invalid decimal string")

// ErrORMIteratorDone defines an error when an iterator is done
ErrORMIteratorDone = Register(ormCodespace, 42, "iterator done")

// ErrORMInvalidIterator defines an error for an invalid iterator
ErrORMInvalidIterator = Register(ormCodespace, 43, "invalid iterator")

// ErrORMUniqueConstraint defines an error when a value already exists at a given key
ErrORMUniqueConstraint = Register(ormCodespace, 44, "unique constraint violation")

// ErrORMEmptyModel defines an error when an empty model is provided for building a table
ErrORMEmptyModel = Register(ormCodespace, 45, "invalid argument")

// ErrORMKeyMaxLength defines an error when a key exceeds max length
ErrORMKeyMaxLength = Register(ormCodespace, 46, "index key exceeds max length")

// ErrORMEmptyKey defines an error for an empty key
ErrORMEmptyKey = Register(ormCodespace, 47, "cannot use empty key")
)

// Register returns an error instance that should be used as the base for
Expand Down
6 changes: 5 additions & 1 deletion x/group/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ require (
pgregory.net/rapid v0.4.7
)

require github.com/tendermint/tm-db v0.6.4

require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/armon/go-metrics v0.3.9 // indirect
Expand All @@ -22,6 +24,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/confio/ics23/go v0.6.6 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/iavl v0.17.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
Expand All @@ -33,6 +36,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
Expand All @@ -45,6 +49,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -65,7 +70,6 @@ require (
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tendermint v0.34.13 // indirect
github.com/tendermint/tm-db v0.6.4 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
Expand Down
Loading