Skip to content

Commit

Permalink
Merge pull request #160 from hashcloak/update-iavl
Browse files Browse the repository at this point in the history
core: update iavl and tendermint
  • Loading branch information
sc0Vu authored Nov 29, 2022
2 parents c613320 + d5fb572 commit 9156436
Show file tree
Hide file tree
Showing 12 changed files with 2,715 additions and 229 deletions.
6 changes: 3 additions & 3 deletions client/pkiclient/katzenmint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"fmt"

"github.com/cosmos/iavl"
costypes "github.com/cosmos/cosmos-sdk/store/types"
kpki "github.com/hashcloak/Meson/katzenmint"
"github.com/hashcloak/Meson/katzenmint/s11n"
"github.com/katzenpost/core/crypto/eddsa"
Expand Down Expand Up @@ -245,7 +245,7 @@ func NewPKIClient(cfg *PKIClientConfig) (*PKIClient, error) {
return kp, nil
})
p.light = lightrpc.NewClient(provider, lightclient, kpFunc)
p.light.RegisterOpDecoder(iavl.ProofOpIAVLValue, iavl.ValueOpDecoder)
p.light.RegisterOpDecoder(costypes.ProofOpIAVLCommitment, costypes.CommitmentOpDecoder)
return p, nil
}

Expand All @@ -254,7 +254,7 @@ func NewPKIClientFromLightClient(light *lightrpc.Client, logBackend *log.Backend
p := new(PKIClient)
p.log = logBackend.GetLogger("pki/client")
p.light = light
p.light.RegisterOpDecoder(iavl.ProofOpIAVLValue, iavl.ValueOpDecoder)
p.light.RegisterOpDecoder(costypes.ProofOpIAVLCommitment, costypes.CommitmentOpDecoder)
return p, nil
}

Expand Down
2 changes: 1 addition & 1 deletion client/pkiclient/katzenmint_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (

"github.com/stretchr/testify/require"

dbm "github.com/cosmos/cosmos-db"
log "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/light"
"github.com/tendermint/tendermint/light/provider/http"
"github.com/tendermint/tendermint/rpc/client/local"
rpctest "github.com/tendermint/tendermint/rpc/test"
dbm "github.com/tendermint/tm-db"
)

var (
Expand Down
41 changes: 19 additions & 22 deletions client/pkiclient/katzenmint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
// ics23 "github.com/confio/ics23/go"
"github.com/cosmos/iavl"

ics23 "github.com/confio/ics23/go"
dbm "github.com/cosmos/cosmos-db"
costypes "github.com/cosmos/cosmos-sdk/store/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/merkle"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
Expand All @@ -30,7 +33,6 @@ import (
rpcmock "github.com/tendermint/tendermint/rpc/client/mocks"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
)

var (
Expand All @@ -47,35 +49,28 @@ func getEpoch(abciClient rpcclient.Client, require *require.Assertions) uint64 {
}

type testOp struct {
Tree *iavl.MutableTree
Key []byte
Proof *iavl.RangeProof
Proof *ics23.CommitmentProof
}

func (op testOp) GetKey() []byte {
return op.Key
}

func (op testOp) ProofOp() tmcrypto.ProofOp {
proof := iavl.NewValueOp(op.Key, op.Proof)
return proof.ProofOp()
return costypes.NewIavlCommitmentOp(op.Key, op.Proof).ProofOp()
}

func (op testOp) Run(args [][]byte) ([][]byte, error) {
root := op.Proof.ComputeRootHash()
switch len(args) {
case 0:
if err := op.Proof.Verify(root); err != nil {
return nil, fmt.Errorf("root did not verified: %+v", err)
}
case 1:
if err := op.Proof.VerifyAbsence(args[0]); err != nil {
return nil, fmt.Errorf("proof did not verified: %+v", err)
}
default:
return nil, fmt.Errorf("args must be length 0 or 1, got: %d", len(args))
func (op testOp) Run(args [][]byte) (root []byte, err error) {
exist := op.Proof.GetExist()
if exist == nil {
return nil, fmt.Errorf("proof did not existed")
}

return [][]byte{root}, nil
if root, err = op.Tree.WorkingHash(); err != nil {
return nil, fmt.Errorf("cannot get root hash: %+v", err)
}
return root, nil
}

// TestMockPKIClientGetDocument tests PKI Client get document and verifies proofs.
Expand All @@ -100,18 +95,20 @@ func TestMockPKIClientGetDocument(t *testing.T) {
require.Equal(n, len(docSer))

// create iavl tree
tree, err := iavl.NewMutableTree(dbm.NewMemDB(), 100)
tree, err := iavl.NewMutableTree(dbm.NewMemDB(), 100, true)
require.NoError(err)

isUpdated, err := tree.Set(key, value)
require.NoError(err)
require.False(isUpdated)

rawDoc, proof, err := tree.GetWithProof(key)
proof, err := tree.GetMembershipProof(key)
require.NoError(err)
rawDoc := proof.GetExist().Value
require.Equal(rawDoc, docSer)

testOp := &testOp{
Tree: tree,
Key: key,
Proof: proof,
}
Expand Down Expand Up @@ -165,7 +162,7 @@ func TestMockPKIClientGetDocument(t *testing.T) {
lc.On("VerifyLightBlockAtHeight", context.Background(), int64(2), mock.AnythingOfType("time.Time")).Return(
&types.LightBlock{
SignedHeader: &types.SignedHeader{
Header: &types.Header{AppHash: rootHash[0]},
Header: &types.Header{AppHash: rootHash},
},
},
nil,
Expand Down
117 changes: 32 additions & 85 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,110 +1,57 @@
module github.com/hashcloak/Meson

go 1.17
go 1.16

require (
git.schwanenlied.me/yawning/aez.git v0.0.0-20180408160647-ec7426b44926
git.schwanenlied.me/yawning/avl.git v0.0.0-20180224045358-04c7c776e391
git.schwanenlied.me/yawning/bloom.git v0.0.0-20181019144233-44d6c5c71ed1
github.com/BurntSushi/toml v1.1.0
github.com/cosmos/iavl v0.19.0
github.com/fxamacker/cbor/v2 v2.3.0
github.com/BurntSushi/toml v1.2.0
github.com/confio/ics23/go v0.7.0
github.com/cosmos/iavl v0.19.2-0.20221019080720-401725aea1a0
github.com/fxamacker/cbor/v2 v2.2.0
github.com/hashcloak/Meson-plugin v0.0.0-20200627021923-d4745a3c9e02
github.com/jackc/pgx v3.6.2+incompatible
github.com/katzenpost/authority v0.0.19
github.com/katzenpost/authority v0.0.14
github.com/katzenpost/client v0.0.3
github.com/katzenpost/core v0.0.15
github.com/katzenpost/registration_client v0.0.3
github.com/prometheus/client_golang v1.12.1
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.19
github.com/katzenpost/core v0.0.12
github.com/katzenpost/registration_client v0.0.1
github.com/prometheus/client_golang v1.14.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.22
github.com/tendermint/tm-db v0.6.7
github.com/ugorji/go/codec v1.2.6
github.com/ugorji/go/codec v1.1.7
go.etcd.io/bbolt v1.3.6
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9
golang.org/x/text v0.3.7
golang.org/x/net v0.1.0
golang.org/x/text v0.4.0
gopkg.in/eapache/channels.v1 v1.1.0
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
)

require (
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/btcsuite/btcd v0.22.3 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/klauspost/compress v1.15.12 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
golang.org/x/sys v0.2.0 // indirect
)

require (
git.schwanenlied.me/yawning/bsaes.git v0.0.0-20190320102049-26d1add596b6 // indirect
github.com/DataDog/zstd v1.4.1 // indirect
cloud.google.com/go/iam v0.4.0 // indirect
cosmossdk.io/math v1.0.0-beta.3 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/OneOfOne/xxhash v1.2.5 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/circl v1.0.1-0.20210104183656-96a0695de3c3 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dchest/siphash v1.2.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de // indirect
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
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/orderedcode v0.0.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/katzenpost/chacha20 v0.0.0-20190910113340-7ce890d6a556 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/cosmos/cosmos-db v0.0.0-20220822060143-23a8145386c0
github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect
github.com/cosmos/cosmos-sdk v0.46.0-rc3
github.com/hashicorp/go-getter v1.6.2 // indirect
github.com/katzenpost/noise v0.0.2 // indirect
github.com/katzenpost/server v0.0.12
github.com/kr/pretty v0.3.0 // indirect
github.com/lib/pq v1.10.4 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/onsi/gomega v1.17.0 // 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
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Loading

0 comments on commit 9156436

Please sign in to comment.