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 graceful shutdown in Fluffy #2645

Merged
merged 4 commits into from
Sep 20, 2024
Merged

Conversation

bhartnett
Copy link
Contributor

No description provided.

@@ -50,7 +50,7 @@ type
GetBoolCallback* = proc(): bool {.gcsafe, raises: [].}
GetSlotCallback* = proc(): Slot {.gcsafe, raises: [].}

LightClientManager* = object
LightClientManager* = ref object
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to change this to a ref object so that the stop proc can become async

Copy link
Contributor

Choose a reason for hiding this comment

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

And making LightClientManager in the stop call a var did not help?

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 tried that and it didn't work. This was the error: Error: 'self' is of type <var LightClientManager> which cannot be captured as it would violate memory safety, declared here: /home/user/development/status-im/nimbus-eth1/fluffy/network/beacon/beacon_light_client_manager.nim(323, 12); using '-d:nimNoLentIterators' helps in some cases. Consider using a <ref var LightClientManager> which can be captured.

@@ -45,7 +45,7 @@ proc start*(n: BeaconNode) =
n.beaconNetwork.start()

proc stop*(n: BeaconNode) {.async.} =
n.beaconNetwork.stop()
discard n.beaconNetwork.stop()
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 these can just await also now?

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 tried that but it slows down and even breaks the tests in some cases. Probably because the tests stop and start the network multiple times. Adding the discard effectively allows the tests to behave as before.

Comment on lines 52 to 54
metricsServer*: Opt[MetricsHttpServerRef]
rpcHttpServer*: Opt[RpcHttpServer]
rpcWsServer*: Opt[RpcWebSocketServer]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a big fan of adding these to the PortalNode object.

Conceptually, to be a part of the Portal network as a node you don't require these more user faced features.
PortalNode is also there to be able to easily integrate our portal node in for example nimbus-eth1 binary. And while these are optional, you still end up importing rpcserver and chronos_httpserver.

If we want to make this more streamlined then I would rather create another object called PortalClient that holds all these servers + PortalNode + interacts with anything cli config related.

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 see your point. Yeah I wasn't sure about this part either. Okay, I'll move them out and clean them up separately for now. I'll keep the PortalClient idea for a separate PR.

@bhartnett bhartnett merged commit 0719396 into master Sep 20, 2024
10 checks passed
@bhartnett bhartnett deleted the fluffy-handle-shutdown branch September 20, 2024 12:54
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.

2 participants