Skip to content

Commit

Permalink
Merge pull request cosmos#77 from tendermint/bucky/update-for-tm0.22
Browse files Browse the repository at this point in the history
remove tmlibs. use tendermint/libs and tendermint/crypto/tmhash
  • Loading branch information
liamsi authored Jul 3, 2018
2 parents 9b23ee1 + 66472f4 commit 7e6d604
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 128 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.8.2

* Swap `tmlibs` for `tendermint/libs`
* Remove `sha256truncated` in favour of `tendermint/crypto/tmhash` - same hash
function but technically a breaking change to the API, though unlikely to effect anyone.

NOTE this means IAVL is now dependent on Tendermint Core for the libs (since it
makes heavy use of the `db` package). Ideally, that dependency would be
abstracted away, and/or this repo will be merged into the Cosmos-SDK, which is
currently is primary consumer. Once it achieves greater stability, we could
consider breaking it out into it's own repo again.

## 0.8.1

*July 1st, 2018*
Expand Down
24 changes: 12 additions & 12 deletions Gopkg.lock

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

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
version = "1.1.4"

[[constraint]]
version = "0.10.1"
version = "=0.10.1"
name = "github.com/tendermint/go-amino"

[[constraint]]
version = "0.9.0-rc1"
name = "github.com/tendermint/tmlibs"
version = "=0.22.0-rc2"
name = "github.com/tendermint/tendermint"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tmlibs/db"
"github.com/tendermint/tendermint/libs/db"
)

func TestBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/tendermint/iavl"
db "github.com/tendermint/tmlibs/db"
db "github.com/tendermint/tendermint/libs/db"
)

const historySize = 20
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Basic usage of VersionedTree.
//
// import "github.com/tendermint/iavl"
// import "github.com/tendermint/tmlibs/db"
// import "github.com/tendermint/tendermint/libs/db"
// ...
//
// tree := iavl.NewVersionedTree(db.NewMemDB(), 128)
Expand Down
10 changes: 5 additions & 5 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"io"

"github.com/tendermint/go-amino"
"github.com/tendermint/iavl/sha256truncated"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
)

// Node represents a node in a Tree.
Expand Down Expand Up @@ -199,7 +199,7 @@ func (node *Node) _hash() []byte {
return node.hash
}

h := sha256truncated.New()
h := tmhash.New()
buf := new(bytes.Buffer)
if err := node.writeHashBytes(buf); err != nil {
panic(err)
Expand All @@ -217,7 +217,7 @@ func (node *Node) hashWithCount() ([]byte, int64) {
return node.hash, 0
}

h := sha256truncated.New()
h := tmhash.New()
buf := new(bytes.Buffer)
hashCount, err := node.writeHashBytesRecursively(buf)
if err != nil {
Expand Down Expand Up @@ -254,7 +254,7 @@ func (node *Node) writeHashBytes(w io.Writer) cmn.Error {
}
// Indirection needed to provide proofs without values.
// (e.g. proofLeafNode.ValueHash)
valueHash := sha256truncated.Hash(node.value)
valueHash := tmhash.Sum(node.value)
err = amino.EncodeByteSlice(w, valueHash)
if err != nil {
return cmn.ErrorWrap(err, "writing value")
Expand Down
2 changes: 1 addition & 1 deletion nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"sync"

dbm "github.com/tendermint/tmlibs/db"
dbm "github.com/tendermint/tendermint/libs/db"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/tendermint/go-amino"
"github.com/tendermint/iavl/sha256truncated"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
)

var (
Expand Down Expand Up @@ -54,7 +54,7 @@ func (pin proofInnerNode) StringIndented(indent string) string {
}

func (pin proofInnerNode) Hash(childHash []byte) []byte {
hasher := sha256truncated.New()
hasher := tmhash.New()
buf := new(bytes.Buffer)

err := amino.EncodeInt8(buf, pin.Height)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (pln proofLeafNode) StringIndented(indent string) string {
}

func (pln proofLeafNode) Hash() []byte {
hasher := sha256truncated.New()
hasher := tmhash.New()
buf := new(bytes.Buffer)

err := amino.EncodeInt8(buf, 0)
Expand Down
2 changes: 1 addition & 1 deletion proof_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

cmn "github.com/tendermint/tmlibs/common"
cmn "github.com/tendermint/tendermint/libs/common"
)

// pathWithLeaf is a path to a leaf node and the leaf node itself.
Expand Down
10 changes: 5 additions & 5 deletions proof_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

"github.com/tendermint/iavl/sha256truncated"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
)

type RangeProof struct {
Expand Down Expand Up @@ -63,7 +63,7 @@ func (proof *RangeProof) VerifyItem(i int, key, value []byte) error {
if !bytes.Equal(proof.Leaves[i].Key, key) {
return cmn.ErrorWrap(ErrInvalidProof, "leaf key not same")
}
valueHash := sha256truncated.Hash(value)
valueHash := tmhash.Sum(value)
if !bytes.Equal(proof.Leaves[i].ValueHash, valueHash) {
return cmn.ErrorWrap(ErrInvalidProof, "leaf value hash not same")
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (t *Tree) getRangeProof(keyStart, keyEnd []byte, limit int) (proof *RangePr
values = append(values, left.value)
var leaves = []proofLeafNode{proofLeafNode{
Key: left.key,
ValueHash: sha256truncated.Hash(left.value),
ValueHash: tmhash.Sum(left.value),
Version: left.version,
}}

Expand Down Expand Up @@ -328,7 +328,7 @@ func (t *Tree) getRangeProof(keyStart, keyEnd []byte, limit int) (proof *RangePr
// Append leaf to leaves.
leaves = append(leaves, proofLeafNode{
Key: node.key,
ValueHash: sha256truncated.Hash(node.value),
ValueHash: tmhash.Sum(node.value),
Version: node.version,
})
// Append value to values.
Expand Down
2 changes: 1 addition & 1 deletion proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/tendermint/go-amino"
"github.com/tendermint/tmlibs/test"
"github.com/tendermint/tendermint/libs/test"
)

func TestTreeGetWithProof(t *testing.T) {
Expand Down
50 changes: 0 additions & 50 deletions sha256truncated/sha256truncated.go

This file was deleted.

32 changes: 0 additions & 32 deletions sha256truncated/sha256truncated_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
mrand "math/rand"

"github.com/tendermint/go-amino"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/db"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
)

func dummyPathToLeaf(t *Tree, key []byte) PathToLeaf {
Expand Down
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

dbm "github.com/tendermint/tmlibs/db"
dbm "github.com/tendermint/tendermint/libs/db"
)

// Tree is a container for an immutable AVL+ Tree. Changes are performed by
Expand Down
4 changes: 2 additions & 2 deletions tree_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/db"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
)

// This file implement fuzz testing by generating programs and then running
Expand Down
4 changes: 2 additions & 2 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/tendermint/tmlibs/db"
"github.com/tendermint/tendermint/libs/db"

cmn "github.com/tendermint/tmlibs/common"
cmn "github.com/tendermint/tendermint/libs/common"
)

var testLevelDB bool
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package iavl

const Version = "0.8.1"
const Version = "0.8.2"
4 changes: 2 additions & 2 deletions versioned_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"fmt"

cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
)

var ErrVersionDoesNotExist = fmt.Errorf("version does not exist")
Expand Down
Loading

0 comments on commit 7e6d604

Please sign in to comment.