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

Startup related fixes #1126

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

GeorgeTsagk
Copy link
Member

This PR fixes some startup related bugs that were discovered when integrating tapd with litd.

Read more here

Closes #1122

@GeorgeTsagk GeorgeTsagk self-assigned this Sep 17, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10907521166

Details

  • 0 of 33 (0.0%) changed or added relevant lines in 3 files are covered.
  • 16 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.007%) to 40.392%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcperms/interceptor.go 0 8 0.0%
tapchannel/aux_funding_controller.go 0 9 0.0%
server.go 0 16 0.0%
Files with Coverage Reduction New Missed Lines %
tapchannel/aux_funding_controller.go 1 0.0%
tapdb/addrs.go 2 79.04%
asset/asset.go 2 81.61%
commitment/tap.go 3 84.17%
tapdb/universe.go 4 80.91%
tapgarden/caretaker.go 4 68.5%
Totals Coverage Status
Change from base Build 10901514108: -0.007%
Covered Lines: 24215
Relevant Lines: 59950

💛 - Coveralls

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice fixes, thanks. Needs some additional checks though.

select {
case <-s.ready:
return nil
case <-s.quit:
Copy link
Member

Choose a reason for hiding this comment

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

I think this doesn't solve the tapd: don't set initialized=true when startup (StartAsSubserver) fails part of the issue. We don't close the quit channel when we fail to start there (which is the main entrypoint for litd).

if info.Server == nil {
return nil, fmt.Errorf("server is nil, can't check " +
"RPC state")

Copy link
Member

Choose a reason for hiding this comment

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

nit: linter complains about superfluous empty line.

@@ -413,6 +413,12 @@ func (r *InterceptorChain) rpcStateUnaryServerInterceptor() grpc.UnaryServerInte
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {

if info.Server == nil {
return nil, fmt.Errorf("server is nil, can't check " +
Copy link
Member

Choose a reason for hiding this comment

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

Can probably be a bit less specific in the error message here, perhaps just "cannot handle call, server not ready"?

case <-s.quit:
return fmt.Errorf("tapd is shutting down")

default:
Copy link
Member

Choose a reason for hiding this comment

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

Nice fix. This probably explains one class of potential errors we had.


default:
select {
case <-s.ready:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe mention here that we now wait until the server becomes ready or shuts down (meaning this is blocking).

func (s *Server) CanHandle(msg protofsm.PeerMsg) bool {
<-s.ready
func (s *Server) CanHandle(msg protofsm.PeerMsg) (bool, error) {
err := s.waitForReady()
Copy link
Member

Choose a reason for hiding this comment

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

Depending on the discussion on the lnd PR it might be okay to just return false if s.waitForReady() returns an error. But calling s.waitForReady() should definitely be done so we don't block indefinitely.

@dstadulis dstadulis added this to the v0.4.2 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

Block RPC calls if not properly started or errored out during start
4 participants