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

Add RPC daemon using Silkworm #8486

Merged
merged 4 commits into from
Oct 17, 2023
Merged

Add RPC daemon using Silkworm #8486

merged 4 commits into from
Oct 17, 2023

Conversation

canepat
Copy link
Contributor

@canepat canepat commented Oct 16, 2023

This introduces experimental RPC daemon run by embedded Silkworm library. Same notes as in PR #8353 apply here plus the following ones:

  • activated if http command-line option is enabled and silkworm.path option is present, nothing more is required (i.e. currently, both block execution and RPC daemon run by Silkworm when specifying silkworm.path, just to keep things as simple as possible)
  • only Execution API endpoints are implemented by Silkworm RPCDaemon, whilst Engine API endpoints are still served by Erigon RPCDaemon
  • some features are still missing, in particular:
    • state change notification handling
    • custom JSON RPC settings (i.e. Erigon RPC settings are not passed to Silkworm yet)

eth/backend.go Outdated
s.logger.Error(err.Error())
return
}
defer s.silkworm.StopRpcDaemon()
Copy link
Collaborator

@AskAlexSharov AskAlexSharov Oct 17, 2023

Choose a reason for hiding this comment

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

maybe you did mean:

go func() {
    select {
    case <-ctx.Done():  // it's just a Ctrl+C listener
       s.silkworm.StopRpcDaemon()
    }
}{}
s.silkworm.StartRpcDaemon()

?

Copy link
Contributor Author

@canepat canepat Oct 17, 2023

Choose a reason for hiding this comment

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

I did it that way because the existing cli.StartRpcServer call blocks the calling goroutine and StartRpcDaemon does not, so I replicated the same behaviour; in other words, StartRpcServer calls startRegularRpcServer, which uses a pattern similar to mine (i.e. defer + <- ctx.Done()).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, and if it blocks - then only way to get to this line of code - “exit without error” - which means server already don’t need shutdown.

In my head “StopRpcDaemon” can gracefuly stop working server. We need call it at “Ctrl+C”

Copy link
Contributor Author

@canepat canepat Oct 17, 2023

Choose a reason for hiding this comment

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

OK, now I see it, I changed the code

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, ok. can add it to name like "StartInBackground" - because most of go's funcs are blocking.

@AskAlexSharov AskAlexSharov merged commit 9568567 into devel Oct 17, 2023
7 checks passed
@AskAlexSharov AskAlexSharov deleted the silkworm_rpcdaemon branch October 17, 2023 23:37
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.

None yet

2 participants