Skip to content

Commit

Permalink
move the protobuf stuff out of iavl
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jan 3, 2023
1 parent 402e595 commit 44c6963
Show file tree
Hide file tree
Showing 15 changed files with 725 additions and 96 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cosmossdk.io/math v1.0.0-beta.3
github.com/armon/go-metrics v0.4.1
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/gogoproto v1.4.2
github.com/cosmos/iavl v0.19.4
github.com/cosmos/ibc-go/v5 v5.1.0
github.com/ethereum/go-ethereum v1.10.19
Expand Down Expand Up @@ -195,7 +196,7 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.7

// https://github.com/yihuang/iavl/tree/dump_changeset
github.com/cosmos/iavl => github.com/yihuang/iavl v0.16.1-0.20221214100032-1b51da1adfde
github.com/cosmos/iavl => github.com/yihuang/iavl v0.16.1-0.20230103093747-1b1febf19315
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.19-deepcopy-jumptable
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.20.1-cronos

Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1/go.mod h1:JUMM2MxF9wuwzRWZJjb8BjXs
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogoproto v1.4.2 h1:UeGRcmFW41l0G0MiefWhkPEVEwvu78SZsHBvI78dAYw=
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/ibc-go/v5 v5.0.0-beta1/go.mod h1:9mmcbzuidgX7nhafIKng/XhXAHDEnRqDjGy/60W1cvg=
Expand Down Expand Up @@ -2368,8 +2369,8 @@ github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G
github.com/yeya24/promlinter v0.2.0/go.mod h1:u54lkmBOZrpEbQQ6gox2zWKKLKu2SGe+2KOiextY+IA=
github.com/yihuang/grocksdb v1.7.11-0.20221223014353-a4fa14d1759b h1:wMYs9akWGUHRJZDsnmN0gLJWHI9UZ+nmCxyk7bqWiwY=
github.com/yihuang/grocksdb v1.7.11-0.20221223014353-a4fa14d1759b/go.mod h1:0hTf+iA+GOr0jDX4CgIYyJZxqOH9XlBh6KVj8+zmF34=
github.com/yihuang/iavl v0.16.1-0.20221214100032-1b51da1adfde h1:3AQFHIYxeTw7wi+xrHlSZhr7oXhwRXMnQWp2zSaJOZQ=
github.com/yihuang/iavl v0.16.1-0.20221214100032-1b51da1adfde/go.mod h1:qaDgN1K91Zd9xaUVxOdlv57rlcOYd6q0a6t/AddnrJQ=
github.com/yihuang/iavl v0.16.1-0.20230103093747-1b1febf19315 h1:AXwjK/MdsQ/e/beygqg5lxpxBTkHq+GOUlhgKoVFqFQ=
github.com/yihuang/iavl v0.16.1-0.20230103093747-1b1febf19315/go.mod h1:qaDgN1K91Zd9xaUVxOdlv57rlcOYd6q0a6t/AddnrJQ=
github.com/yihuang/tm-db v0.0.0-20230103092224-3f21822ed03e h1:2aFuR5EgQO3C/MHXqLUAlvmQRJ9xuWd9z8VdeqtMsVs=
github.com/yihuang/tm-db v0.0.0-20230103092224-3f21822ed03e/go.mod h1:QWum/v2n8t5yeFSQu7J2YsrwB7qB3D3RM+snYzAKG5M=
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
Expand Down
7 changes: 5 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ schema = 3
[mod."github.com/cosmos/go-bip39"]
version = "v1.0.0"
hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA="
[mod."github.com/cosmos/gogoproto"]
version = "v1.4.2"
hash = "sha256-hOY+mhPDYWcSYSdth2AW7IONdgicqQir0z/1XrXt9NY="
[mod."github.com/cosmos/iavl"]
version = "v0.16.1-0.20221214100032-1b51da1adfde"
hash = "sha256-CWEslCOMf5TerOTnPgmQebDeTYS+EjO/zu850Pqugco="
version = "v0.16.1-0.20230103093747-1b1febf19315"
hash = "sha256-/Q2V4Vgxef8oBaLy3/P/S2crZh554KIbkYAss1hEMFg="
replaced = "github.com/yihuang/iavl"
[mod."github.com/cosmos/ibc-go/v5"]
version = "v5.1.0"
Expand Down
4 changes: 2 additions & 2 deletions proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ deps:
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: bee5511075b7499da6178d9e4aaa628b
commit: 34d970b699f84aa382f3c29773a60836
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 80720a488c9a414bb8d4a9f811084989
commit: 783e4b5374fa488ab068d08af9658438
13 changes: 13 additions & 0 deletions proto/changeset.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";

option go_package = "github.com/crypto-org-chain/cronos/versiondb";

message KVPair {
bool delete = 1;
bytes key = 2;
bytes value = 3;
}

message ChangeSet {
repeated KVPair pairs = 1;
}
52 changes: 26 additions & 26 deletions versiondb/backend_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,45 +124,45 @@ func testBasics(t *testing.T, store VersionStore) {
require.Equal(t, value1, value)
}

type KVPair struct {
type kvPair struct {
Key []byte
Value []byte
}

func testIterator(t *testing.T, store VersionStore) {
SetupTestDB(t, store)

expItems := [][]KVPair{
expItems := [][]kvPair{
{
KVPair{[]byte("delete-in-block2"), []byte("1")},
KVPair{[]byte("modify-in-block2"), []byte("1")},
KVPair{[]byte("re-add-in-block3"), []byte("1")},
KVPair{[]byte("z-genesis-only"), []byte("2")},
kvPair{[]byte("delete-in-block2"), []byte("1")},
kvPair{[]byte("modify-in-block2"), []byte("1")},
kvPair{[]byte("re-add-in-block3"), []byte("1")},
kvPair{[]byte("z-genesis-only"), []byte("2")},
},
{
KVPair{[]byte("add-in-block1"), []byte("1")},
KVPair{[]byte("delete-in-block2"), []byte("1")},
KVPair{[]byte("modify-in-block2"), []byte("1")},
KVPair{[]byte("z-genesis-only"), []byte("2")},
kvPair{[]byte("add-in-block1"), []byte("1")},
kvPair{[]byte("delete-in-block2"), []byte("1")},
kvPair{[]byte("modify-in-block2"), []byte("1")},
kvPair{[]byte("z-genesis-only"), []byte("2")},
},
{
KVPair{[]byte("add-in-block1"), []byte("1")},
KVPair{[]byte("add-in-block2"), []byte("1")},
KVPair{[]byte("modify-in-block2"), []byte("2")},
KVPair{[]byte("z-genesis-only"), []byte("2")},
kvPair{[]byte("add-in-block1"), []byte("1")},
kvPair{[]byte("add-in-block2"), []byte("1")},
kvPair{[]byte("modify-in-block2"), []byte("2")},
kvPair{[]byte("z-genesis-only"), []byte("2")},
},
{
KVPair{[]byte("add-in-block1"), []byte("1")},
KVPair{[]byte("add-in-block2"), []byte("1")},
KVPair{[]byte("modify-in-block2"), []byte("2")},
KVPair{[]byte("re-add-in-block3"), []byte("2")},
KVPair{[]byte("z-genesis-only"), []byte("2")},
kvPair{[]byte("add-in-block1"), []byte("1")},
kvPair{[]byte("add-in-block2"), []byte("1")},
kvPair{[]byte("modify-in-block2"), []byte("2")},
kvPair{[]byte("re-add-in-block3"), []byte("2")},
kvPair{[]byte("z-genesis-only"), []byte("2")},
},
{
KVPair{[]byte("add-in-block1"), []byte("1")},
KVPair{[]byte("add-in-block2"), []byte("1")},
KVPair{[]byte("modify-in-block2"), []byte("2")},
KVPair{[]byte("z-genesis-only"), []byte("2")},
kvPair{[]byte("add-in-block1"), []byte("1")},
kvPair{[]byte("add-in-block2"), []byte("1")},
kvPair{[]byte("modify-in-block2"), []byte("2")},
kvPair{[]byte("z-genesis-only"), []byte("2")},
},
}
for i, exp := range expItems {
Expand Down Expand Up @@ -257,10 +257,10 @@ func testHeightInFuture(t *testing.T, store VersionStore) {
require.NoError(t, err)
}

func consumeIterator(it dbm.Iterator) []KVPair {
var result []KVPair
func consumeIterator(it dbm.Iterator) []kvPair {
var result []kvPair
for ; it.Valid(); it.Next() {
result = append(result, KVPair{it.Key(), it.Value()})
result = append(result, kvPair{it.Key(), it.Value()})
}
it.Close()
return result
Expand Down
Loading

0 comments on commit 44c6963

Please sign in to comment.