Skip to content

Verify all headers in order instead of bisect#3360

Closed
liamsi wants to merge 11 commits intodevelopfrom
ismail/lite_dont_bisect
Closed

Verify all headers in order instead of bisect#3360
liamsi wants to merge 11 commits intodevelopfrom
ismail/lite_dont_bisect

Conversation

@liamsi
Copy link
Contributor

@liamsi liamsi commented Feb 28, 2019

resolves: #3259
ref: #3244
ref: #3174

Still need to address the TODOs below but this should be ready for review.

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

 - add method that fetches, verifies, and stores all headers in order
 from the latest trusted up to the requested height
@codecov-io
Copy link

codecov-io commented Feb 28, 2019

Codecov Report

Merging #3360 into develop will decrease coverage by 0.26%.
The diff coverage is 46.93%.

@@             Coverage Diff             @@
##           develop    #3360      +/-   ##
===========================================
- Coverage    64.42%   64.15%   -0.27%     
===========================================
  Files          214      214              
  Lines        17514    17552      +38     
===========================================
- Hits         11283    11261      -22     
- Misses        5296     5350      +54     
- Partials       935      941       +6
Impacted Files Coverage Δ
lite/commit.go 48.83% <30.76%> (+0.11%) ⬆️
lite/dynamic_verifier.go 49.35% <52.77%> (-18.99%) ⬇️
privval/signer_service_endpoint.go 83.63% <0%> (-5.46%) ⬇️
libs/events/events.go 93.2% <0%> (-4.86%) ⬇️
consensus/reactor.go 70.36% <0%> (-2.13%) ⬇️
consensus/state.go 78.82% <0%> (-0.24%) ⬇️
blockchain/reactor.go 72.46% <0%> (+0.96%) ⬆️
blockchain/pool.go 81.69% <0%> (+2.03%) ⬆️
consensus/ticker.go 95.83% <0%> (+4.16%) ⬆️

// Update height for height.
// TODO: do we want the lite client to store the intermediate commits,
// or only the latest/last one?
if err := dv.verifyAndSave(trustedFC, nextFC); err != nil {
Copy link
Contributor Author

@liamsi liamsi Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this but there are actually no reasons to save the intermediate full-commits here, right?
@ebuchman @melekes @cwgoes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we benefit from storing them? maybe only that if something fails, we'll start from the last saved commit, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only benefit would be that if the application constantly queries state of the past, we have more trusted (verified) full commits / signed headers stored locally which can be used as a starting point for this queries instead having to query them from dv.source. My intuition would be that storing the last header / full commit should be sufficient but this intuition is not based on any numbers/data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to query past state, we need past Merkle roots (app hashes). I don't think we need the full commits though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris. Probably just storing the latest full commit should be enough. The full commit contains the AppHashes via the Header:

type FullCommit struct {
SignedHeader types.SignedHeader `json:"signed_header"`
Validators *types.ValidatorSet `json:"validator_set"`
NextValidators *types.ValidatorSet `json:"next_validator_set"`
}

tendermint/types/block.go

Lines 689 to 690 in 15f6211

type SignedHeader struct {
*Header `json:"header"`

AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block

We could probably get rid of some (most?) of the fields here for the lite client.

For now, storing only the latest FullCommit sounds like the most reasonable thing to do.

@liamsi liamsi requested a review from cwgoes February 28, 2019 13:27
@liamsi
Copy link
Contributor Author

liamsi commented Feb 28, 2019

Although this is still WIP but I appreciate a first quick early review as I'm new to the lite package.
cc @cwgoes @ebuchman @melekes

// Souce doesn't have fcz[9] so cert.LastTrustedHeight wont' change.
// We do not jump forward using trusted full commits.
// Instead, we need to store the "gap" (height 7) in source s.t.
// Verfiy can retrieve it from somewhere.

This comment was marked as resolved.

liamsi added 3 commits March 1, 2019 12:45
- only verify that valset for height SignedHeader.Height+1 is non-empty and
matches the hash in the signed header (NextValidatorsHash)
- all other checks were already done by the BaseVerifier
- at least log mysteriously ignored error (for now)
// for height h, using repeated applications of bisection if necessary.
//
// Returns ErrCommitNotFound if source provider doesn't have the commit for h.
// TODO: bisection is disabled for now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you link the issue here too

return FullCommit{}, err
}
// We already were at the requested height.
if trustedFC.Height() == h {

This comment was marked as resolved.

This comment was marked as resolved.

// Update height for height.
// TODO: do we want the lite client to store the intermediate commits,
// or only the latest/last one?
if err := dv.verifyAndSave(trustedFC, nextFC); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we benefit from storing them? maybe only that if something fails, we'll start from the last saved commit, no?

@liamsi liamsi changed the title WIP: Verify all headers in order instead of bisect Verify all headers in order instead of bisect Mar 20, 2019
@jaekwon
Copy link
Contributor

jaekwon commented Mar 24, 2019

#3259 (comment)

Instead of merging this in, I'll incorporate some fixes into a new branch I'm working on for weak subjectivity.

@jaekwon jaekwon closed this Mar 24, 2019
@xla xla deleted the ismail/lite_dont_bisect branch March 28, 2019 08:15
iKapitonau pushed a commit to scrtlabs/tendermint that referenced this pull request Sep 30, 2024
…rovided by a seed node (backport tendermint#3360) (tendermint#3396)

Closes tendermint#486.

Commits:

1. Make `TestConnectionSpeedForPeerReceivedFromSeed` to fail, as it will
make the node to connect to more than the configured
`MaxNumOutboundPeers`
2. Solve the issue by introducing a channel to wake up
`ensurePeersRoutine()`. In this way, the node will not to wait until the
next `defaultEnsurePeersPeriod` (30s) before attempting again to connect
to new peers (`ensurePeers()` method) whose addresses were provide by
the seed node.

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request tendermint#3360 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
cboh4 pushed a commit to scrtlabs/tendermint that referenced this pull request Apr 7, 2025
…rovided by a seed node (backport tendermint#3360) (tendermint#3397)

Closes tendermint#486.

Commits:

1. Make `TestConnectionSpeedForPeerReceivedFromSeed` to fail, as it will
make the node to connect to more than the configured
`MaxNumOutboundPeers`
2. Solve the issue by introducing a channel to wake up
`ensurePeersRoutine()`. In this way, the node will not to wait until the
next `defaultEnsurePeersPeriod` (30s) before attempting again to connect
to new peers (`ensurePeers()` method) whose addresses were provide by
the seed node.

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request tendermint#3360 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants