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 scaffolding for sentinel integration #5672

Closed
wants to merge 7 commits into from

Conversation

frrist
Copy link
Member

@frrist frrist commented Feb 24, 2021

What

  • add sentinel module scaffolding and API
  • add ldflag to build lotus in "SentinelMode" with make command lotus-sentinel.

TODO

  • Figure out how to make docs-check green.
    • currently fails panic: no perms for method: WatchStart but WatchStart has perms admin

@frrist frrist force-pushed the sentinel/module-scaffold branch from 9b8c48d to c7393e9 Compare February 24, 2021 01:36
@frrist frrist force-pushed the sentinel/module-scaffold branch from c7393e9 to e3a757b Compare February 24, 2021 21:09
@frrist frrist changed the title WIP: Scaffolding for Sentinel Implement scaffolding for sentinel integration Feb 24, 2021
@frrist frrist self-assigned this Feb 24, 2021
@frrist frrist force-pushed the sentinel/module-scaffold branch from c8a92fd to 8fb82ea Compare February 24, 2021 22:32
@frrist frrist marked this pull request as ready for review February 24, 2021 22:37
@frrist frrist requested a review from iand February 24, 2021 22:38
@frrist frrist added area/api kind/feature Kind: Feature labels Feb 24, 2021
- allows lotus to be started in sentinel mode and start a watch that logs
tipsets as they are received.
- replaces the sentinel flag on daemon command.
@frrist frrist force-pushed the sentinel/module-scaffold branch from 8fb82ea to 6789392 Compare February 24, 2021 22:49
Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just a couple of comments/discussion points.

Docsgen is unhappy, probably because it expects flat interfaces (make docsgen / likely broken somewhere here - https://github.com/filecoin-project/lotus/blob/master/api/docgen/docgen.go#L411-L504)

api/apistruct/struct.go Outdated Show resolved Hide resolved
api/api_sentinel.go Outdated Show resolved Hide resolved
@@ -470,6 +471,12 @@ type WalletStruct struct {
}
}

type SentinelStruct struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be easier to have the sentinel methods be defined on the FullNodeStruct struct, so it doesn't have to be registered in all the random places

Copy link
Member Author

Choose a reason for hiding this comment

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

While I agree it would be easier, I believe separation will make future work simpler to land as changes will only occur in sentinel-related structures and files. I think this is a bit cleaner too. But, if you feel strongly about defining methods on the FullNodeStruct, we can do it that way instead.

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.

Looks good and not too intrusive.

But I'd like us to explore how we could make it even less intrusive, mainly to hedge our bets while we continue to explore possibilities for less coupling between sentinel and Lotus.

What would the changes look like if we had a separate binary to run that imported all the necessary parts of Lotus daemon? Could we inject the module from that code instead of adding it to the various Lotus packages?

This would avoid the clunky build flag but also potentially allows that binary to live outside the Lotus codebase

@@ -0,0 +1,3 @@
package build

var SentinelMode string = "false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting and parsing this seems really clunky. Is this the pattern already in use by Lotus? If so then let's leave it (but it's still clunky!)

In theory the Go compiler could optimize away code that isn't needed for sentinel mode but I think this would have to be a const bool for that to work.

I feel that fx must have better support for compile time switching of modules.

Copy link
Member Author

Choose a reason for hiding this comment

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

The only prior art I saw for this was passing the version via a build flag. @magik6k wants to avoid adding more flags to the daemon and suggested a build flag or a go plugin. If, as you've already suggested, I can pull the required bits into a separate binary, then I think this flag can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unless separate binary, using build tags might be cleaner: go build -tags sentinel. It also forces to separate everything sentinel-specific to its own files.

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've implemented a standalone binary here: #5693

@frrist
Copy link
Member Author

frrist commented Mar 3, 2021

going with #5693

@frrist frrist closed this Mar 3, 2021
@Kubuxu Kubuxu deleted the sentinel/module-scaffold branch November 25, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Sentinel module scaffolding to Lotus
4 participants