lite: Add synchronization in lite verify#2396
lite: Add synchronization in lite verify#2396ebuchman merged 4 commits intotendermint:developfrom HaoyangLiu:bianjie/improve-lite
Conversation
…all Certify to Verify
cwgoes
left a comment
There was a problem hiding this comment.
One question but code changes look OK to me otherwise. Can we add a few testcases to ensure that this works correctly?
| //Get the exact trusted commit for h, and if it is | ||
| // equal to shdr, then don't even verify it, | ||
| // and just return nil. | ||
| trustedFCSameHeight, err := ic.trusted.LatestFullCommit(ic.chainID, shdr.Height, shdr.Height) |
There was a problem hiding this comment.
Is this stored in RAM or on disk?
There was a problem hiding this comment.
Both of them will store the commits. Here we create disk db and memory db to cache the verified commits:
tendermint/lite/proxy/verifier.go
Line 16 in d419fff
Actually, I have changed the test to cover the new code. Next I will create a new test to simulate concurrent requests.
There was a problem hiding this comment.
On-disk we can store all, in-memory should be an LRU cache with a configurable size.
|
Very cool. Has this been tested HaoyangLiu? What are the next steps? |
|
@cwgoes |
Codecov Report
@@ Coverage Diff @@
## develop #2396 +/- ##
==========================================
- Coverage 61.75% 61.25% -0.5%
==========================================
Files 198 197 -1
Lines 16358 16337 -21
==========================================
- Hits 10102 10008 -94
- Misses 5434 5463 +29
- Partials 822 866 +44
|
This sounds OK, parameterize cache size is definitely a good idea. Probably enough for now. |
xla
left a comment
There was a problem hiding this comment.
👍
🍡
Some minor formatting changes, otherwise LGTM.
lite/dynamic_verifier.go
Outdated
| lerr "github.com/tendermint/tendermint/lite/errors" | ||
| "github.com/tendermint/tendermint/types" | ||
| "sync" | ||
| "fmt" |
There was a problem hiding this comment.
Import order is incorrect it should be:
import (
// stdlib packages
// third-party packages
// repo package
)
lite/dynamic_verifier_test.go
Outdated
|
|
||
| dbm "github.com/tendermint/tendermint/libs/db" | ||
| log "github.com/tendermint/tendermint/libs/log" | ||
| "sync" |
| ) | ||
|
|
||
| func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger) (*lite.DynamicVerifier, error) { | ||
| func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger, cacheSize int) (*lite.DynamicVerifier, error) { |
There was a problem hiding this comment.
This signature is getting quite large, would benefit from functional options, an example from another part of the codebase:
Lines 41 to 54 in 0c9c329
There was a problem hiding this comment.
@xla
I think function options may be not suitable for NewVerifier. Because NewVerifier use these parameters for processing network operation, not just variable assignment.
|
@xla |
| source Provider | ||
|
|
||
| // pending map for synchronize concurrent verification requests | ||
| pendingVerifications map[int64]chan struct{} |
There was a problem hiding this comment.
Convention we use is to put the mtx directly above the things it protects.
Implement the idea in #2386
CertifytoVerify