Commit Graph

6261 Commits

Author SHA1 Message Date
2679b7554b lite: comment out iavl code - TODO #1183 2018-02-03 03:02:49 -05:00
5a4f56056e Merge pull request #189 from tendermint/no-wire-crypto
remove go-wire and go-crypto deps
2018-02-03 02:55:22 -05:00
1148027baf remove go-wire and go-crypto deps 2018-02-03 02:39:34 -05:00
21dd648732 Merge pull request #187 from tendermint/no-iavl
Remove IAVL dependency
2018-02-03 02:26:26 -05:00
baea45177d example/dummy: remove iavl dep - just use raw db 2018-02-03 02:02:40 -05:00
deaaf014d8 Merge pull request #141 from tendermint/no-wire
merkle: remove go-wire dep by copying EncodeByteSlice
2018-02-03 01:57:27 -05:00
951333ecb0 common: IsHex should be able to handle 0X prefixed strings
IsHex should also successfully decode strings prefixed with
0X instead of only 0x strings.

Also add tests generally for IsHex.
2018-02-02 23:41:24 -07:00
d6d97889f2 merkle: remove go-wire dep by copying EncodeByteSlice 2018-02-03 01:29:39 -05:00
c617737e03 Merge pull request #184 from tendermint/sdk2
update for go-wire sdk2
2018-02-03 00:22:50 -05:00
4450a20bde types: check bufio.Reader 2018-02-03 00:24:48 -05:00
d2845d923b add more versions to glide 2018-02-03 00:14:15 -05:00
700792bc10 update glide 2018-02-03 00:08:39 -05:00
11d383f1c7 update for go-wire sdk2 2018-02-02 23:56:19 -05:00
4fc3055dbd update glide again 2018-02-02 23:50:24 -05:00
1d7fc78ea1 update glide 2018-02-02 23:49:14 -05:00
5a94049dbc update glide again 2018-02-02 23:42:22 -05:00
9e897ab8b0 update glide 2018-02-02 23:34:07 -05:00
690d6c6070 cli: WriteDemoConfig -> WriteConfigVals 2018-02-02 23:05:28 -05:00
4542cc5a71 Merge pull request #64 from tendermint/sdk2
Merge sdk2 into develop
2018-02-02 22:48:01 -05:00
027c37281d Merge pull request #123 from tendermint/sdk2
Merge sdk2 into develop
2018-02-02 22:32:33 -05:00
1b5176003a DbBackend -> DBBackend 2018-02-02 22:31:17 -05:00
45b71f7d11 Bump tmlibs commit. Needs to be changed to develop as soon as tmlibs PR is merged 2018-02-02 18:51:41 +01:00
cbc63518e5 Export DbBackendType in order to fix IAVL tests 2018-02-02 18:50:24 +01:00
0391e499fb Clean up glide.yaml 2018-02-02 18:31:25 +01:00
2e76546223 Clean up glide.yaml 2018-02-02 18:09:48 +01:00
6b2409f714 Update go-wire to develop 2018-02-02 14:12:29 +01:00
95b53c80e1 Merge pull request #140 from tendermint/sdk2-hashers-and-simple-map
Sdk2 hashers and simple map
2018-02-02 14:15:56 +04:00
9ccfe161ad lowercase memDB type key 2018-02-02 14:08:05 +04:00
f6dbe9ba05 Refactor string -> dbBackendType 2018-02-02 14:08:05 +04:00
b95cac5f4f Remove unnecessary Byteser interface 2018-02-02 14:08:05 +04:00
c75298e359 Update SimpleMap to hash both keys and values for benefit; Hashable is Hasher; Don't assume go-wire 2018-02-02 14:08:05 +04:00
580c3db8f9 Hashable -> Hasher; SimpleMap upgrade; No "SimpleHashFromBinary" (#128)
* Update SimpleMap to hash both keys and values for benefit; Hashable is Hasher; Don't assume go-wire
2018-02-02 12:51:30 +04:00
7ef6d4b813 Glide update 2018-02-02 12:51:30 +04:00
ff230682d1 Fix logical time (#122)
Should fix a nondeterministic bug so...
2018-02-02 12:51:30 +04:00
cfbb9338bd use go-wire sdk2 2018-02-02 12:51:30 +04:00
6637c202bf Revert "Update to use tmlibs sdk2"
This reverts commit ae58af0be534a5c344896461b97a6490d428deb4.
Breaks the tests.
2018-02-02 12:51:30 +04:00
4e2a275a67 Update to use tmlibs sdk2 2018-02-02 12:51:30 +04:00
bcd8d403dc Remove encoding from common cli 2018-02-02 12:51:29 +04:00
62c9cad484 Merge pull request #1180 from tendermint/1146-add-BFT-time-spec
Add BFT time spec
2018-02-01 16:38:05 -05:00
4cbdbbaac9 Add BFT time spec 2018-02-01 15:22:08 +01:00
9ed296ae71 GetByHeight switches between linear & binary search on >=50 items
* GetByHeight will now switch to using binary search once
we have  >=50 items.
* Feedback from @ebuchman to catch a missed spot where
we forgot about lazy sorting that the original code
assumed would always have sorted commits by height.
Added a lazy sorting routine here too.
A test as well to ensure that we always get the properly
sorted and last value.
2018-01-31 20:53:03 -07:00
e8d0960cef nolint 2018-01-31 20:52:12 -07:00
2023115ff8 lite: TestCacheGetsBestHeight with GetByHeight and GetByHeightBinarySearch
Addressing PR review requests from @melekes and @ebuchman to
add a test that checks that the heights returned from both are
the same thus providing a perceptible equivalence of the code
linear range search vs binary range search code.
2018-01-31 20:52:12 -07:00
7790ae9e6f Fix spelling mistake 2018-01-31 20:52:12 -07:00
206da7a1b8 lite: < len(v) in for loop check, as per @melekes' recommendation
Also lazily load the commits to only be run once when
the benchmarks are activated, lest it slows down all the tests
2018-01-31 20:52:11 -07:00
14eaba9ec3 lite: memStoreProvider GetHeightBinarySearch method + fix ValKeys.signHeaders
Updates #1021

* Implement a GetHeightBinarySearch method that looks for
the height using the binary search algorithm guaranteeing
worst case iteration time of O(log2(n))
whereas
worst case iteration time of O(n) for the current linear search

So if n we had 500 commits stored by height and sorted, to
trigger the worst case scenario for each, pass in
the most negative height you can find e.g. -1
Linear search: 500 iterations
Binary search: 9 iterations

with n=1000, qHeight = -1
Linear search: 1000 iterations
Binary search: 10 iterations

with n=1e6, qHeight = -1
Linear search: 1e6 iterations
Binary search: 20 iterations

Of course there are realistic expectations e.g. a max of
commits that may be saved so linear search might be useful
for very small size set because it has less preparing overhead
and only ~2 types of comparisons, but nonetheless binary search
shines as soon as we start to hit say 50 commits to search from
as you can see below:

```shell
$ go test -v -run=^$ -bench=MemStore
goos: darwin
goarch: amd64
pkg: github.com/tendermint/tendermint/lite
BenchmarkMemStoreProviderGetByHeightLinearSearch5-4     300000        6491 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch50-4      200000       12064 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch100-4      50000       32987 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch500-4       5000      395521 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch1000-4	       500     2940724 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch5-4     300000        6281 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch50-4      200000       10117 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch100-4     100000       18447 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch500-4      20000       89029 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch1000-4	      5000      265719 ns/op      1600 B/op       15 allocs/op
PASS
ok    github.com/tendermint/tendermint/lite 86.614s
$ go test -v -run=^$ -bench=MemStore
goos: darwin
goarch: amd64
pkg: github.com/tendermint/tendermint/lite
BenchmarkMemStoreProviderGetByHeightLinearSearch5-4     300000        6779 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch50-4      100000       12980 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch100-4      30000       43598 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch500-4       5000      377462 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightLinearSearch1000-4	       500     3278122 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch5-4     300000        7084 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch50-4      200000        9852 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch100-4     100000       19020 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch500-4      20000       99463 ns/op      1600 B/op       15 allocs/op
BenchmarkMemStoreProviderGetByHeightBinarySearch1000-4	      5000      259293 ns/op      1600 B/op       15 allocs/op
PASS
ok    github.com/tendermint/tendermint/lite 86.204s
```

which gives
```shell
$ benchstat old.txt new.txt
name                               old time/op    new time/op    delta
MemStoreProviderGetByHeight5-4       6.63µs ± 2%    6.68µs ± 6%   ~             (p=1.000 n=2+2)
MemStoreProviderGetByHeight50-4      12.5µs ± 4%    10.0µs ± 1%   ~             (p=0.333 n=2+2)
MemStoreProviderGetByHeight100-4     38.3µs ±14%    18.7µs ± 2%   ~             (p=0.333 n=2+2)
MemStoreProviderGetByHeight500-4      386µs ± 2%      94µs ± 6%   ~             (p=0.333 n=2+2)
MemStoreProviderGetByHeight1000-4    3.11ms ± 5%    0.26ms ± 1%   ~             (p=0.333 n=2+2)
```

If need be we can make a hybrid algorithm that switches between the
linear and binary search depending on the number of items.
This is reminiscent of Python's TimSort algorithm.
2018-01-31 20:52:11 -07:00
2919bc3f7f Merge pull request #1178 from tendermint/nice-err-msg
improve error message
2018-01-31 21:32:58 -05:00
1c01671ec6 improve vague error msg, closes #1158 2018-01-31 17:44:19 +00:00
af30cef574 Coin changes for Peng's faucet 2018-01-30 09:45:05 -05:00
13f009bf68 Merge pull request #136 from tendermint/fix-bitArray-nil-update
common: fix BitArray.Update to avoid nil dereference
2018-01-29 17:17:18 -05:00