Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Visor Vector Builder & Executor #370

Merged
merged 10 commits into from
Feb 19, 2021
Merged

Conversation

frrist
Copy link
Member

@frrist frrist commented Jan 26, 2021

What

This PR adds vector creation and execution logic to Visor. A README with example usage can be viewed here: https://github.com/filecoin-project/sentinel-visor/pull/370/files?short_path=405134e#diff-405134e8ddb86a9f71f27944fd2349c9f86062c1797bce502dcfb32fb36f693f. There is a lot of room for improvement here, but given this PR's age, the churn from the past couple weeks, and changing priorities, I wanted to put a pin in this. I intend to make further improvements to this as follow-ons.

How to review

Look over the README linked above, then read commit by commit.

@iand I have created 85eb065df81f0ab2688530772c72f078344c9bab to serve as a strawman for starting a conversation on how to fix #374.

Here is a demo showing how to create and execute visor test vectors.
asciicast

@frrist frrist changed the title wip: add camera lens Visor Vector WIP Jan 26, 2021
@frrist frrist force-pushed the frrist/vector-builder branch 3 times, most recently from b2e13e4 to 17c8329 Compare February 16, 2021 22:14
@frrist frrist changed the title Visor Vector WIP Visor Vector Builder Feb 16, 2021
@frrist frrist self-assigned this Feb 16, 2021
@@ -19,3 +19,4 @@ visor
sentinel-visor

build/.*
vector/data/*.json
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensure the vector files don't get pushed to github.

Comment on lines +76 to +77
// wrap the repos blockstore with a tracing implementation capturing all cid's read.
capi.tbs = NewTracingBlockstore(bs)
Copy link
Member Author

Choose a reason for hiding this comment

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

Wrapping the API's blockstore with a TracingBlockstore tracks CIDs read from it. The recorded CIDs are used to build the vectors CAR data.

@@ -0,0 +1,63 @@
package storage
Copy link
Member Author

Choose a reason for hiding this comment

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

Implement the storage interfaces backed by a map.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

}

func modelTypeFromTable(tableName string, expected json.RawMessage, actual []interface{}) (string, error) {
// TODO: something with reflection someday
Copy link
Member Author

@frrist frrist Feb 17, 2021

Choose a reason for hiding this comment

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

It was faster for me to just write this all out than tinker with reflection.

This method validates the data extracted while executing the test vector matches the expectation of the vector.

@frrist frrist marked this pull request as ready for review February 17, 2021 01:14
@filecoin-project filecoin-project deleted a comment from codecov-io Feb 17, 2021
@frrist frrist requested review from iand and placer14 February 17, 2021 01:16
@frrist frrist force-pushed the frrist/vector-builder branch from 2d2aa0b to 8646a14 Compare February 17, 2021 01:25
Copy link
Contributor

@iand iand left a comment

Choose a reason for hiding this comment

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

Generally LGTM. Mostly cosmetic comments.

chain/indexer.go Outdated
ll.Debugw("tipset complete", "total_time", time.Since(start))
}()
wg.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

This will force the extraction and persistence to be locked in step, but they are supposed to be out of step. The idea is that we can be extracting a tipset while persisting the previous one (which is mostly IO wait).

Can you take this out and let's figure out a fix for #374 separately

Copy link
Member Author

Choose a reason for hiding this comment

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

I have reverted this change here: 288beafa4673e74bbaf3fa024799254f06e61f1e
And applied a hacky-fix here: fb47362dbd11c562b63478b001f871691d0ef6f7

I agree this, nor the hack are the correct solution, but without one of them all vector tests fail. I believe this is because once the walker has indexed the last tipset in its walk it calls this method and exists regardless of this go routine completing its persistence work.

Copy link
Contributor

Choose a reason for hiding this comment

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

😢

commands/setup.go Outdated Show resolved Hide resolved
commands/vector.go Outdated Show resolved Hide resolved
commands/vector.go Outdated Show resolved Hide resolved
commands/vector.go Outdated Show resolved Hide resolved
lens/vector/tracing_bs.go Outdated Show resolved Hide resolved
@@ -0,0 +1,63 @@
package storage
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

```
Finally, execute the vector unit tests:
```
$ go test -v ./vector/...
Copy link
Contributor

Choose a reason for hiding this comment

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

Tried these commands out and it all worked smoothly. 🏆

Copy link
Contributor

Choose a reason for hiding this comment

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

haha, spoke too soon. One vector failed to download correctly and the file contains

<html>
<head><title>429 Too Many Requests</title></head>
<body>
<center><h1>429 Too Many Requests</h1></center>
<hr><center>openresty</center>
</body>
</html>

Copy link
Member Author

@frrist frrist Feb 18, 2021

Choose a reason for hiding this comment

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

Damn, ideally the curl command in fetch_vectors.sh would be ipfs or ipget but I didn't want to muck with those in CI just yet. I have modified fetch_vectors.sh to fail in the event curl fails, and I think that should address this... 🥈

vector/fetch_vectors.sh Show resolved Hide resolved
@frrist frrist force-pushed the frrist/vector-builder branch 2 times, most recently from fb47362 to e6370b8 Compare February 18, 2021 22:42
Users may use the vector lens to capture all CID's written to and
read from its API. The lens may be used in conjunction with the
vector commands to produce a test vector.
Implement vector build and vector runner commands.
These commands allow a user to build and execute vectors against Visor.
This reverts commit 85eb065df81f0ab2688530772c72f078344c9bab.
- will revert after a proper fix is designed.
@frrist
Copy link
Member Author

frrist commented Feb 18, 2021

Need to regenerate the message vector after the rebase, then should be ready for merge.

@frrist frrist force-pushed the frrist/vector-builder branch from e6370b8 to 69afaa0 Compare February 18, 2021 23:46
@codecov-io
Copy link

Codecov Report

Merging #370 (6dcf1ec) into master (daf7e2b) will decrease coverage by 2.5%.
The diff coverage is 34.1%.

@@           Coverage Diff            @@
##           master    #370     +/-   ##
========================================
- Coverage    46.4%   43.9%   -2.6%     
========================================
  Files          24      29      +5     
  Lines        1796    2258    +462     
========================================
+ Hits          835     993    +158     
- Misses        834    1083    +249     
- Partials      127     182     +55     

@frrist frrist changed the title Visor Vector Builder Implement Visor Vector Builder & Executor Feb 19, 2021
@frrist frrist merged commit dcc5517 into master Feb 19, 2021
@frrist frrist deleted the frrist/vector-builder branch February 19, 2021 18:03
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.

TipSetIndexer task result persistence race condition
3 participants