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

Create a Lily node by embedding lotus into visor to observe tipset apply and revert events #408

Merged
merged 11 commits into from
Mar 11, 2021

Conversation

frrist
Copy link
Member

@frrist frrist commented Mar 3, 2021

What

The PR imports and embeds the lotus daemon into Visro; currently, this node is called Lily.
Changes required to lotus live here: filecoin-project/lotus#5693

Usage

  1. make (may need to run git submodule update --init --recursive first)
  2. ./visor lily daemon --import-snapshot minimal_finality_stateroots_517061_2021-02-20_11-00-00.car
  3. make dockerup to create a database
  4. ./visor lily watch start will instruct lily to start watching and processing the Filecoin blockchain and indexing it to the database.

@frrist frrist self-assigned this Mar 4, 2021
@frrist frrist marked this pull request as draft March 4, 2021 19:17
@frrist frrist changed the base branch from master to lily March 8, 2021 20:25
-- will allow lotus binary to be built in following commit
@frrist frrist changed the title WIP: make a lotus+visor node binary Create a Lily node by embed lotus into visor to observe tipset apply and revert events Mar 8, 2021
@frrist frrist changed the title Create a Lily node by embed lotus into visor to observe tipset apply and revert events Create a Lily node by embedding lotus into visor to observe tipset apply and revert events Mar 8, 2021
@frrist frrist requested review from placer14 and iand and removed request for placer14 March 8, 2021 22:04
- allows a lotus node to be instanciated and for visor to observe
tipsets applied and reverted by the lotus node.

obs := observer.NewIndexingTipSetObserver(indexer, tsCache)

if err := m.Events.Observe(obs); err != nil {
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 think we can avoid this dependency in lotus if we go back to using the chain notify API call that is already present in the impl.FullNodeAPI.

@@ -0,0 +1,26 @@
package apistruct
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a separate package?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not -- I had everything broken into packages like this to make it easier to mimic lotus's layout. I have sense created a "lily" lens and moved the LilyNode API and struct into it.

@@ -0,0 +1,282 @@
package cli
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to our commands package?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

return opts
}

func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just a copy of what is in Lotus? We talked about exporting it in Lotus but copying it here means one less change on the Lotus side which is good.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should find a better package for this function, although it's not urgent to do that

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, a copy from lotus; I agree copying this code isn't ideal but I would prefer to punt on extraction in lotus since this copy is low risk.

node/main.go Outdated
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"SENTINEL_LOTUS_PATH"},
Copy link
Contributor

Choose a reason for hiding this comment

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

SENTINEL_REPO perhaps? Let's start being consistent so a flag called xxx has an env variable called SENTINEL_XXX


var log = logging.Logger("lily-api")

type LilyNodeStruct struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is the start of the new JSON-RPC API that visor will expose to allow the daemon to be controlled we should name it more concretely, e.g. just API.

Would be nice if we could stop using the word node in other places where we mean lens.Interface and we should try to stop using it here too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dropped the "node" word and moved this all to the lens package

var log = logging.Logger("lily-api")

type LilyNodeStruct struct {
lotusstruct.FullNodeStruct
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need all of this. What is the minimum we need?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the following API's from lotus:

  • common.CommonAPI for the RPC and authentication/permissions.
  • full.ChainAPI for chain event notification and chain inspection.
  • full.StateAPI for actor state extraction and inspection.

I have redeclared the LilyAPI to require only these.

@frrist frrist marked this pull request as ready for review March 9, 2021 20:30
@@ -0,0 +1,148 @@
package util
Copy link
Member Author

Choose a reason for hiding this comment

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

mostly copy-paste from lotus to get the injection working.

Name: "lens",
EnvVars: []string{"VISOR_LENS"},
Value: "lotus",
Destination: &commands.VisorCmdFlags.Lens,
Copy link
Member Author

Choose a reason for hiding this comment

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

Destination looks like a cleaner way (imo) to pass values to subcommands, e.g. lily watch start

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah maybe. I'm not 100% sold on it but willing to try it out.

@iand iand self-requested a review March 10, 2021 15:00
@codecov-io
Copy link

Codecov Report

Merging #408 (79231aa) into lily (8f367a3) will decrease coverage by 0.2%.
The diff coverage is 0.0%.

@@           Coverage Diff           @@
##            lily    #408     +/-   ##
=======================================
- Coverage   43.9%   43.6%   -0.3%     
=======================================
  Files         28      29      +1     
  Lines       2246    2261     +15     
=======================================
  Hits         986     986             
- Misses      1076    1091     +15     
  Partials     184     184             

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.

I'm happy to merge this to lily and use it as a basis for the next steps.

return nil
}

var _ events.TipSetObserver = (*IndexingTipSetObserver)(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is the only reason for importing the events package. I don't think we need it since we can't compile without it satisfying the interface anyway

"github.com/filecoin-project/lotus/chain/types"
)

func NewIndexingTipSetObserver(obs TipSetObserver, cache *TipSetCache) *IndexingTipSetObserver {
Copy link
Contributor

Choose a reason for hiding this comment

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

As you mentioned before, we could simply revert to using ChainNotify and then this type is redundant with Watcher. For now let's keep it and work on refactoring to a more optimized lens interface that could work by calling ChainNotiify or could hook into events directly.

After: destroy,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "indexhead-confidence",
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll refine the names of the params later

Name: "lens",
EnvVars: []string{"VISOR_LENS"},
Value: "lotus",
Destination: &commands.VisorCmdFlags.Lens,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah maybe. I'm not 100% sold on it but willing to try it out.

@frrist frrist merged this pull request into lily Mar 11, 2021
@frrist frrist deleted the frrist/visor-lotus branch March 11, 2021 18:59
frrist added a commit that referenced this pull request Mar 11, 2021
frrist added a commit that referenced this pull request Mar 22, 2021
iand pushed a commit that referenced this pull request Apr 20, 2021
…ply and revert events (#408)

chore: reuse watcher in lily watch command (#422)

Merge master into lily (#425)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

fix(linter): make deps before linting in CI (#437)

merge master into lily (#432)

* fix(indexer): only close TIpSetIndexer in walk and watch
* chore: increase linter timeout in ci

scheduler job control + watch, walk, and job cli (#414)

merge master into lily (#442)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

Co-authored-by: Ian Davis <[email protected]>
Co-authored-by: Peter Rabbitson <[email protected]>

chore: remove confidence argument from lily walk command (#444)

chore: reorganise visor commands (#445)

feat: add storage configuration to daemon (#446)

* feat: add storage configuration to daemon

* Start wiring up storage to config

* Finish wiring up storage config

* check error return when ensuring config

* Close config file on error

feat: Add --api parameter to daemon client commands (#450)

* feat: Add --api parameter to daemon client commands

* Make api default value a valid multiaddr

* Add api token parameter

Merge master into lily (#463)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

* Release notes for v0.5.5 (#440)

* chore: update lotus to 1.6.0 (#443)

* chore: upgrade lotus dependency to 1.6.0-rc1 (#447)

* chore: update lotus to 1.6.0 (#455)

* Release notes for v0.5.6 (#456)

* fix: ensure persistence semaphore channel is drained on close (#457)

* fix: ensure persistence semaphore channel is drained on close

* Add hidden window flag for testing

* Reduce actor happy path logging

* Make sure actor errors reported are appended to correct list

* Release notes for v0.5.7 (#458)

* Update to latest lotus commit

* Add missing support/tools/go.sum

* Fix merge bugs in makefile

* Fix merge bugs in makefile

Co-authored-by: Peter Rabbitson <[email protected]>
Co-authored-by: frrist <[email protected]>

feat: clean up command line flags for single-run jobs (#464)

* feat: clean up command line flags for single-run jobs
* Fix dockerfile

Co-authored-by: frrist <[email protected]>

polish(lily): add job name flag (#467)

- closes #452

polish(job): print job type, params, and errors in list (#468)

- closes #451

fix: ensure event channel is initialised before watch starts (#471)

chore: merge master into lily branch (#472)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

* Release notes for v0.5.5 (#440)

* chore: update lotus to 1.6.0 (#443)

* chore: upgrade lotus dependency to 1.6.0-rc1 (#447)

* chore: update lotus to 1.6.0 (#455)

* Release notes for v0.5.6 (#456)

* fix: ensure persistence semaphore channel is drained on close (#457)

* fix: ensure persistence semaphore channel is drained on close

* Add hidden window flag for testing

* Reduce actor happy path logging

* Make sure actor errors reported are appended to correct list

* Release notes for v0.5.7 (#458)

* fix(tasks): use correct ActorInfo for actor state extraction (#449)

* fix(tasks): use corret actor info for actor state extraction
- fixes #273

* fix(lens): remove OptimizedStateGetActorWithFallback
- fixes #405

* fix(market-task): fix market actor task and gen vector
- fixes #465

* polish(vector): support msapproval model validation

* test(vector): generate new test vectors

* ci: increase instance size due to test vectors

* Add MinerSectorInfo for extended sectors (#448)

Fixes #441. Extended sectors have new deadlines but this is not recorded anywhere.

* Fix makefile conflicts

Co-authored-by: Peter Rabbitson <[email protected]>
Co-authored-by: frrist <[email protected]>
Co-authored-by: Hector Sanjuan <[email protected]>
iand added a commit that referenced this pull request Apr 20, 2021
* Create a Lily node by embedding lotus into visor to observe tipset apply and revert events (#408)

* chore: reuse watcher in lily watch command (#422)

* Merge master into lily (#425)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* fix(linter): make deps before linting in CI (#437)

* merge master into lily (#432)

* fix(indexer): only close TIpSetIndexer in walk and watch
* chore: increase linter timeout in ci

* scheduler job control + watch, walk, and job cli (#414)

* merge master into lily (#442)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

Co-authored-by: Ian Davis <[email protected]>
Co-authored-by: Peter Rabbitson <[email protected]>

* chore: remove confidence argument from lily walk command (#444)

* chore: reorganise visor commands (#445)

* feat: add storage configuration to daemon (#446)

* feat: add storage configuration to daemon

* Start wiring up storage to config

* Finish wiring up storage config

* check error return when ensuring config

* Close config file on error

* feat: Add --api parameter to daemon client commands (#450)

* feat: Add --api parameter to daemon client commands

* Make api default value a valid multiaddr

* Add api token parameter

* Merge master into lily (#463)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

* Release notes for v0.5.5 (#440)

* chore: update lotus to 1.6.0 (#443)

* chore: upgrade lotus dependency to 1.6.0-rc1 (#447)

* chore: update lotus to 1.6.0 (#455)

* Release notes for v0.5.6 (#456)

* fix: ensure persistence semaphore channel is drained on close (#457)

* fix: ensure persistence semaphore channel is drained on close

* Add hidden window flag for testing

* Reduce actor happy path logging

* Make sure actor errors reported are appended to correct list

* Release notes for v0.5.7 (#458)

* Update to latest lotus commit

* Add missing support/tools/go.sum

* Fix merge bugs in makefile

* Fix merge bugs in makefile

Co-authored-by: Peter Rabbitson <[email protected]>
Co-authored-by: frrist <[email protected]>

* feat: clean up command line flags for single-run jobs (#464)

* feat: clean up command line flags for single-run jobs
* Fix dockerfile

Co-authored-by: frrist <[email protected]>

* polish(lily): add job name flag (#467)

- closes #452

* polish(job): print job type, params, and errors in list (#468)

- closes #451

* fix: ensure event channel is initialised before watch starts (#471)

* chore: merge master into lily branch (#472)

* fix: ignore false positive gosec failure in wait package (#421)

* fix: embed genesis block in executable (#420)

* feat: add benchmarking of vectors (#423)

* feat: add benchmarking of vectors

* feat: add benchmarking of vectors

* Use nicer test and benchmark names

* Chore/sqlotus dag prefetch option (#430)

* Disable preloader by default, toggle with LOTUS_CHAINSTORE_PRELOAD_RECENTS

* Switch to a cli string as suggested by @iand

* Remove one more inefficiency for the R/O lens

filecoin-project/go-bs-postgres-chainnotated@b8b5d500e368d2ed

* Forgotten option/helptext spec

* Add support for static Get() prefetch

* close TipSetObs in walker and watcher

* fix(indexer): only close TIpSetIndexer in walk and watch

- subsequent calls to close will hang forever

* chore: increase linter timout in ci

* chore: update for Lotus 1.5.3 (#439)

* chore: update for Lotus 1.5.3

* fixup! chore: update for Lotus 1.5.3

* Update statediff version

Co-authored-by: frrist <[email protected]>

* Release notes for v0.5.5 (#440)

* chore: update lotus to 1.6.0 (#443)

* chore: upgrade lotus dependency to 1.6.0-rc1 (#447)

* chore: update lotus to 1.6.0 (#455)

* Release notes for v0.5.6 (#456)

* fix: ensure persistence semaphore channel is drained on close (#457)

* fix: ensure persistence semaphore channel is drained on close

* Add hidden window flag for testing

* Reduce actor happy path logging

* Make sure actor errors reported are appended to correct list

* Release notes for v0.5.7 (#458)

* fix(tasks): use correct ActorInfo for actor state extraction (#449)

* fix(tasks): use corret actor info for actor state extraction
- fixes #273

* fix(lens): remove OptimizedStateGetActorWithFallback
- fixes #405

* fix(market-task): fix market actor task and gen vector
- fixes #465

* polish(vector): support msapproval model validation

* test(vector): generate new test vectors

* ci: increase instance size due to test vectors

* Add MinerSectorInfo for extended sectors (#448)

Fixes #441. Extended sectors have new deadlines but this is not recorded anywhere.

* Fix makefile conflicts

Co-authored-by: Peter Rabbitson <[email protected]>
Co-authored-by: frrist <[email protected]>
Co-authored-by: Hector Sanjuan <[email protected]>

Co-authored-by: Ian Davis <[email protected]>
Co-authored-by: Peter Rabbitson <[email protected]>
Co-authored-by: Hector Sanjuan <[email protected]>
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.

3 participants