Commit Graph

7711 Commits

Author SHA1 Message Date
Anton Kaliaev
c4f7256766 lite2: store current validator set (#4472)
Before we were storing trustedHeader (height=1) and trustedNextVals
(height=2).

After this change, we will be storing trustedHeader (height=1) and
trustedVals (height=1). This a) simplifies the code b) fixes #4399
inconsistent pairing issue c) gives a relayer access to the current
validator set #4470.

The only downside is more jumps during bisection. If validator set
changes between trustedHeader and the next header (by 2/3 or more), the
light client will be forced to download the next header and check that
2/3+ signed the transition. But we don't expect validator set change too
much and too often, so it's an acceptable compromise.

Closes #4470 and #4399
v0.33.1-dev1
2020-02-26 10:20:51 +01:00
Alessio Treglia
25d92d05f8 types: VerifyCommitX return when +2/3 sigs are verified (#4445)
Closes #4417
2020-02-25 10:04:24 +01:00
Callum Waters
f934ca82fc lite2: don't save intermediate headers (#4452)
closes #4426

The sequence and bisection methods no longer save the intermediate headers and validator sets that they require to verify a currently untrusted header.

## Commits:

* sequence and bisection don't save intermediate headers and vals

* check the next validator hash matches the header

* check expired header at start of backwards verification

* added tests

* handled cleanup warning

* lint fix

* removed redundant code

* tweaked minor errors

* avoided premature trusting of nextVals

* fix test error

* updated trustedHeader and Vals together

* fixed bisection error

* fixed sequence error for different vals and made test

* fixes after my own review

* reorder vars to be consistent

with the rest of the code

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-24 11:10:41 +01:00
Erik Grinaker
fe11219795 Fix unexported returns (#4450) 2020-02-21 19:21:39 +01:00
Erik Grinaker
c63fd32fc2 circleci: run P2P IPv4 and IPv6 tests in parallel (#4459) 2020-02-21 15:23:48 +01:00
Erik Grinaker
8d1198b39a ADR-053: update with implementation plan after prototype (#4427) 2020-02-21 13:28:05 +01:00
Erik Grinaker
b0683b7fc6 p2p: use curve25519.X25519() instead of ScalarMult() (#4449)
* p2p: use curve25519.X25519() instead of ScalarMult()

* Renamed array to shrKeyArray

* Updated CHANGELOG_PENDING

* Revert "Updated CHANGELOG_PENDING"

This reverts commit dbb72e0bf7.
2020-02-21 12:43:59 +01:00
Callum Waters
2c7af01cb6 lite2: return already verified headers and verify earlier headers (#4428)
closes #4413 and #4419

When VerifyHeaderAtHeight() is called, TrustedHeader is initially run to check if the header has already been verified and returns the Header.

If the new header height is less than the lite clients latestTrustedHeader height, than backwards verification is performed else either sequence or bisection

Refactored a test to reflect the changes

* use trustedHeader func for already verified Headers

* remove fetch missing header from TrustedHeader

* check for already trusted Header in VerifyHeaderAtHeight

* replace updateTrustedHeaderAndVals to updateTrustedHeaderAndNextVals

* rename trustedHeader and trustedNextVals

* refactored backwards and included it in VerifyHeader

* cleaned up test to match changes

* lite2: fixes after my own review

Refs https://github.com/tendermint/tendermint/pull/4428#pullrequestreview-361730169

* fix ineffectual assignment

* lite2: check that header exists in VerifyHeader

* extract function

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-20 15:45:11 +01:00
Erik Grinaker
8f48c49543 Fix some golangci-lint warnings (#4448) 2020-02-20 13:43:40 +01:00
dependabot-preview[bot]
8010f3b4df build(deps): bump github.com/spf13/cobra from 0.0.3 to 0.0.6 (#4440)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 0.0.3 to 0.0.6.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v0.0.3...v0.0.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-20 13:31:59 +01:00
dependabot-preview[bot]
d00384f0f5 build(deps): bump github.com/stretchr/testify from 1.5.0 to 1.5.1 (#4441)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.5.0...v1.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-20 13:02:24 +01:00
Erik Grinaker
24c8b351c6 rpc: fix TxSearch test nits (#4446) 2020-02-20 11:34:18 +01:00
dependabot-preview[bot]
7ab81a7fdd deps: bump github.com/stretchr/testify from 1.4.0 to 1.5.0 (#4435)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.4.0...v1.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-19 17:26:23 +01:00
tau3
b7dab3b8ab consensus: reduce log severity for ErrVoteNonDeterministicSignature (#4431)
from error to debug

Closes #3583
2020-02-19 16:21:27 +01:00
Sean Braithwaite
ee993ba8ff blockchain: add v2 reactor (#4361)
The work includes the reactor which ties together all the seperate routines involved in the design of the blockchain v2 refactor. This PR replaces #4067 which got far too large and messy after a failed attempt to rebase.

## Commits:

* Blockchainv 2 reactor:

	+ I cleaner copy of the work done in #4067 which fell too far behind and was a nightmare to rebase.
	+ The work includes the reactor which ties together all the seperate routines involved in the design of the blockchain v2 refactor.

* fixes after merge

* reorder iIO interface methodset

* change iO -> IO

* panic before send nil block

* rename switchToConsensus -> trySwitchToConsensus

* rename tdState -> tmState

* Update blockchain/v2/reactor.go

Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>

* remove peer when it sends a block unsolicited

* check for not ready in markReceived

* fix error

* fix the pcFinished event

* typo fix

* add documentation for processor fields

* simplify time.Since

* try and make the linter happy

* some doc updates

* fix channel diagram

* Update adr-043-blockchain-riri-org.md

* panic on nil switch

* liting fixes

* account for nil block in bBlockResponseMessage

* panic on duplicate block enqueued by processor

* linting

* goimport reactor_test.go

Co-authored-by: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-19 16:00:14 +01:00
Erik Grinaker
403f43a477 rpc: fix txsearch tests (#4438) 2020-02-19 15:36:15 +01:00
Callum Waters
1874a97170 lite: modified bisection to loop (#4400)
refs #4329

As opposed to using recursion to implement the bisection method of verifying a header, which could have problems with memory allocation (especially for smaller devices), the bisection algorithm now uses a for loop.

* modified bisection to loop

* made lint changes

* made lint changes

* move note to VerifyHeader

since it applies both for sequence and bisection

* test bisection jumps to header signed by 1/3+

 of old validator set

* update labels in debug log calls

* copy tc

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-19 15:18:52 +01:00
Erik Grinaker
b09cdaf1af rpc: fix tx_search pagination with ordered results (#4437) 2020-02-19 14:01:42 +01:00
Marko
c680507bab dep: maunally bump dep (#4436)
replaces #4434

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
2020-02-19 13:11:17 +01:00
Erik Grinaker
68f37fff65 Use uint64 for consensus.Reactor.SwitchToConsensus() blocksSynced (#4433) 2020-02-19 12:28:34 +01:00
Marko
6c67e246c3 dep: bump gokit dep (#4424)
* dep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokitdep: bump gokit-

Signedoff-by: Marko Baricevic <marbar3778@yahoo.com>

* go mod tidy

* test go version change

* combination of multiple cmds

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-18 16:20:02 +01:00
Callum Waters
f5901ea460 lite2: divide verify functions (#4412)
Closes #4398

* divided verify functions

* extacted method

* renamed functions. Created standard Verify function

* checked non-adjacency. separated VerifyCommit

* lint fixes

* fix godoc documentation for VerifyAdjacent and VerifyNonAdjacent

* add a comment about VerifyCommit being the last check

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-18 16:10:04 +01:00
Anthony
5ea1ff94d1 rpc: fix issue with multiple subscriptions (#4406)
Using the WebSocket server, when the same client calls multiple time the subscribe method, only the last subscription receives all the events of the previous ones.

example:

    subscription1 = tm.event = 'NewBlock'
    subscription2 = tm.event = 'Tx'

In this case, subscription2 will receive the new blocks but subscription1 will not.

This came from the WebSocket handler that had the declaration of the rpcrequest moved and so overridden for every request and given in the JSONReq client context (so the id of the subscription was not the right one).

This fixes the issue by simply declaring the rpcrequest inside the loop so every request will create a new object without overwriting the previous one.
2020-02-17 08:00:56 +01:00
Denis Fadeev
da8813071b Docs staging (#4407)
* update theme

* Update version

* Updated Questions section in the footer

* Remove links to Riot chat

* Typo

* Add Discord link

Co-authored-by: Marko <marbar3778@yahoo.com>
2020-02-15 21:07:48 +01:00
Anton Kaliaev
c56fd04ab4 lite2: disconnect from bad nodes (#4388)
Closes #4385

* extract TrustOptions into its own file

* print trusted hash before asking whenever to rollback or not

so the user could reset the light client with the trusted header

* do not return an error if rollback is aborted

reason: we trust the old header presumably, so can continue from it.

* add note about time of initial header

* improve logging and add comments

* cross-check newHeader after LC verified it

* check if header is not nil

so we don't crash on the next line

* remove witness if it sends us incorrect header

* require at least one witness

* fix build and tests

* rename tests and assert for specific error

* wrote a test

* fix linter errors

* only check 1/3 if headers diverge
2020-02-14 17:04:56 +01:00
Callum Waters
58620af5e0 lite2: modified sequence method to match bisection (#4403)
Currently the sequence function always starts from the trustedHeader and trustedNextVals stored in the lite client. Whereas the bisection one allows the method to be started from any combination of header and validator set. I opened up the sequence verification method to do the same
2020-02-14 14:52:50 +01:00
Erik Grinaker
5f5e0e1d02 makefile: place phony markers after targets (#4408)
The .PHONY targets in the Makefile are usually placed far away from the actual targets, and thus aren't always updated. Placing the .PHONY targets right next to the targets they cover make them more visible and thus more likely to be updated when necessary.
2020-02-14 14:41:18 +01:00
Anton Kaliaev
3b5794ffe9 adr: light client implementation (#4397)
* adr: light client implementation

Closes #2133

* note on chain IDs

* explain why witnesses are required

* if chain forks maliciously, chain ID stays the same

* add a note about min witnesses while cross-checking
2020-02-14 11:35:14 +01:00
Anton Kaliaev
774aff5f7d docs: update Light Client Protocol page (#4405)
* docs: update Light Client Protocol page

Closes #4331

* one way to get hash & height
2020-02-14 11:22:17 +01:00
Marko
fb5751d2c5 release: minor release 0.33.1 (#4401)
* release: minor release 0.33.1

- minor release for 0.33.1

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* remvoe wording

* version bump
2020-02-13 16:38:00 +01:00
Marko
67837e5f40 readme: fix link to original paper (#4391)
Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
2020-02-12 15:50:07 +01:00
Marko
2b709e79e7 make: remove sentry setup cmds (#4383)
* make: remove sentry setup cmds

removal of make comands for sentry setup. it was unclear if they were being maintained and there has not been a mention of people using them

- closes #4379

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* remove depreacted readme

* add not being maintained section to docs
2020-02-12 12:45:24 +01:00
Erik Grinaker
b712c1cbb5 autofile: resolve relative paths (#4390)
Fixes #2649
2020-02-11 18:20:26 +01:00
Callum Waters
831ed8f96a Merge pull request #4389 from tendermint/callum/clean-lite-tests
refactored lite client tests
2020-02-11 17:46:41 +01:00
Anton Kaliaev
16aae3a361 Merge branch 'master' into callum/clean-lite-tests 2020-02-11 17:35:10 +01:00
Anton Kaliaev
ab6ac6d435 lite2: improve string output of all existing providers (#4387)
before:
&http{AFBSD743A...}

after:
http{https://127.0.0.1:26657}

Co-authored-by: Marko <marbar3778@yahoo.com>
2020-02-11 17:30:26 +01:00
Callum Michael Waters
4787f7c2dd refactored lite client tests 2020-02-11 17:17:48 +01:00
Marko
9a9e8c5bb3 proto: minor linting to proto files (#4386)
* proto: minor linting

minor linting after working with the proto files in the sdk.

there is no logic change just spacing fixes

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* hardcore linting
2020-02-11 15:07:05 +01:00
Marko
c494070b31 docs: fix spec links (#4384)
- erik fixed many of the broken links, just fixed two outstanding ones.

- closes #4381

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-11 10:57:26 +01:00
Callum Waters
da813e4e36 lite2: manage witness dropout (#4380)
* witnesses are dropped after no response

* test witness dropout

* corrected import structure

* moved non responsiveness check to compare function

* removed dropout test as witnesses are never dropped

* created test to compare witnesses
2020-02-11 10:41:58 +01:00
Marko
31fd99a91a proto: add buf and protogen script (#4369)
* proto: add buf and protogen script

- add buf with minimal changes
- add protogen script to easier generate proto files

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* add protoc needs

* add some needed shell cmds

* remove buf from tools as it is not needed everytime

* add proto lint and breakage to ci

* add section in changelog and upgrading files

* address pr comments

* remove space in circle config

* remove spaces in makefile comment

* add section on contributing on how to work with proto

* bump buf to 0.7

* test bufbuild image

* test install make in bufbuild image

* revert to tendermintdev image

* Update Makefile

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-11 10:31:15 +01:00
Anton Kaliaev
aeb6cc475e lite2: return if there are no headers in RemoveNoLongerTrustedHeaders (#4378) v0.33.1-dev0 2020-02-07 16:31:46 +01:00
Erik Grinaker
5ac81eb198 docs: fix incorrect link (#4377) 2020-02-07 15:00:19 +01:00
Anton Kaliaev
b2832c66af lite2: validate TrustOptions, add NewClientFromTrustedStore (#4374)
* validate trust options

* add NewClientFromTrustedStore func

* make maxRetryAttempts an option

Closes #4370

* hash size should be equal to tmhash.Size

* make maxRetryAttempts uint

* make maxRetryAttempts uint16

maxRetryAttempts possible - 68 years

* we do not store trustingPeriod

* added test to create client from trusted store

* remove header and vals from primary

to make sure we're restoring them from the DB
v0.33.0-dev2
2020-02-07 14:37:20 +01:00
Erik Grinaker
66a544a640 Fix broken /docs/spec links (#4376) 2020-02-07 12:53:28 +01:00
dependabot-preview[bot]
3e2f299885 deps: bump google.golang.org/grpc from 1.27.0 to 1.27.1 (#4372)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.27.0 to 1.27.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.27.0...v1.27.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-06 16:51:30 +01:00
Callum Waters
af37db39b0 lite2: cross-check new header with all witnesses (#4373)
As opposed to checking a random witness, all witnesses provided should be used as a reference against the header provided by the primary node. This increases security (at the tradeoff of speed) but also gives control to the user. The more witnesses provided, the more secure the lite client can be.
2020-02-06 15:36:13 +01:00
Callum Waters
bb7a80ec7e lite2: fetch missing headers (#4362)
Closes #4328

When TrustedHeader(height) is called, if the height is less than the trusted height but the header is not in the trusted store then a function finds the previous lowest height with a trusted header and performs a forwards sequential verification to the header of the height that was given. If no error is found it updates the trusted store with the header and validator set for that height and can then return them to the user.

Commits:

* drafted trusted header

* created function to find previous trusted height

* updates missing headers less than the trusted height

* minor cosmetic tweaks

* incorporated suggestions

* lite2: implement Backwards verification

and add SignedHeaderAfter func to Store interface

Refs https://github.com/tendermint/tendermint/issues/4328#issuecomment-581878549

* remove unused method

* write tests

* start with next height in SignedHeaderAfter func

* fix linter errors

* address Callum's comments

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-06 12:30:37 +01:00
Callum Waters
df3eee455c lite2: replace primary provider with alternative when unavailable (#4354)
Closes issue #4338

Uses a wrapper function around both the signedHeader and validatorSet calls to the primary provider which attempts to retrieve the information 5 times before deeming the provider unavailable and replacing the primary provider with the first alternative before trying recursively again (until all alternatives are depleted)

Employs a mutex lock for any operations involving the providers of the light client to ensure no operations occurs whilst the new primary is chosen.

Commits:

* created swapProvider function

* eliminates old primary provider after replacement. Uses a mutex when changing providers

* renamed to replaceProvider

* created wrapped functions for signed header and val set

* created test for primary provider replacement

* implemented suggested revisions

* created Witnesses() and Primary()

* modified backoffAndJitterTime

* modified backoffAndJitterTime

* changed backoff base and jitter to functional arguments

* implemented suggested changes

* removed backoff function

* changed exp function to match go version

* halved the backoff time

* removed seeding and added comments

* fixed incorrect test

* extract backoff timeout calc into a function

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-04 13:02:20 +01:00
Marko
9b9f1beef3 docs: update guides proto paths (#4365)
* update guides with correct path to libs/kv proto files

* Apply suggestions from code review

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

* format something to rerun ci

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
2020-02-03 18:15:27 +01:00