Skip to content

Decouple StartHTTP{,AndTLS}Server from Listen()#2791

Merged
ebuchman merged 12 commits intotendermint:developfrom
alessio:alessio/refactor-http-serve-calls
Nov 15, 2018
Merged

Decouple StartHTTP{,AndTLS}Server from Listen()#2791
ebuchman merged 12 commits intotendermint:developfrom
alessio:alessio/refactor-http-serve-calls

Conversation

@alessio
Copy link
Contributor

@alessio alessio commented Nov 9, 2018

This should help solve cosmos/cosmos-sdk#2715

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

@alessio alessio changed the base branch from master to develop November 9, 2018 13:54
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

🍷 🍞 🧀

if err != nil {
panic(err)
}
if err := rpc.StartHTTPServer(listener, mux, logger); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

goroutine?

Copy link
Contributor

Choose a reason for hiding this comment

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

We either need use a go-routine here or ensure that this is the last thing we call from the main method (ie. let it take the place of TrapSignal). In this case the Table-of-Nodes is created after startRPC, so we'd have to switch the order

@jackzampolin jackzampolin mentioned this pull request Nov 9, 2018
6 tasks
Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Thanks for this - needs a few fixes.

if err != nil {
panic(err)
}
if err := rpc.StartHTTPServer(listener, mux, logger); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We either need use a go-routine here or ensure that this is the last thing we call from the main method (ie. let it take the place of TrapSignal). In this case the Table-of-Nodes is created after startRPC, so we'd have to switch the order

@ebuchman
Copy link
Contributor

Can we get develop merged in and add this as a BREAKING CHANGE to the GO API in the CHANGELOG_PENDING.md (should be v0.26.2). Thanks!

@codecov-io
Copy link

codecov-io commented Nov 12, 2018

Codecov Report

Merging #2791 into develop will decrease coverage by 0.03%.
The diff coverage is 31.42%.

@@            Coverage Diff             @@
##           develop   #2791      +/-   ##
==========================================
- Coverage    62.33%   62.3%   -0.04%     
==========================================
  Files          212     212              
  Lines        17262   17258       -4     
==========================================
- Hits         10760   10752       -8     
- Misses        5602    5606       +4     
  Partials       900     900
Impacted Files Coverage Δ
lite/proxy/proxy.go 0% <0%> (ø) ⬆️
rpc/grpc/client_server.go 81.81% <100%> (+10.38%) ⬆️
node/node.go 63.27% <81.81%> (ø) ⬆️
privval/tcp_server.go 78.57% <0%> (-2.86%) ⬇️
consensus/state.go 80.14% <0%> (-0.36%) ⬇️
state/errors.go 0% <0%> (ø) ⬆️
consensus/reactor.go 69.51% <0%> (+0.34%) ⬆️

@ebuchman
Copy link
Contributor

Non-deterministic failure, rerunning it.

How should we handle go SomeFun where SomeFun returns an error? Currently we're just ignoring them for all the http serves - is that fine ?

@alessio
Copy link
Contributor Author

alessio commented Nov 12, 2018

@ebuchman we should have an error channel IMO

@ebuchman
Copy link
Contributor

we should have an error channel IMO

Sounds right, but we can't just block on it. I guess it should be part of the shut-down sequence to catch that error. Only question is, if the error is from the startup phase, how do we catch it?

Maybe we should open a new issue for this

Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Just need a bit more documentation around the change, otherwise looks good.

Thanks @alessio !

Question - I'd make the final changes myself but this branch is in your repo. Is there an easy way for me to do such a thing without having to fetch your branch and open a new PR ?

@@ -20,25 +17,10 @@ type Config struct {
// StartGRPCServer starts a new gRPC BroadcastAPIServer, listening on
// protoAddr, in a goroutine. Returns a listener and an error, if it fails to
// parse an address.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment. Should also state that the function is blocking.

)

// StartHTTPServer starts an HTTP server on listenAddr with the given handler.
// StartHTTPServer takes a listener and start an HTTP server with the given handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should mention that the function is blocking.

// handler.


// StartHTTPAndTLSServer takes a listener and start an HTTP server with the given handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention the function is blocking.

@alessio
Copy link
Contributor Author

alessio commented Nov 14, 2018

@ebuchman dixit:

I'd make the final changes myself but this branch is in your repo.

You take over here? You want me to do something else?

@ebuchman ebuchman merged commit b646437 into tendermint:develop Nov 15, 2018
panic(err)
}
}()
listener2, err := server.Listen(unixAddr, server.Config{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
listener2, err := server.Listen(unixAddr, server.Config{})
listener2, err := server.Listen(unixAddr, server.Config{})
if err != nil {
panic(err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I will fix.

@alessio alessio deleted the alessio/refactor-http-serve-calls branch November 23, 2018 08:51
iKapitonau pushed a commit to scrtlabs/tendermint that referenced this pull request Jul 10, 2024
…mint#2791) (tendermint#2793)

The cosmos-sdk 0.50 genesis doc marshalling not being compatible with
the cometbft default one (see
cosmos/cosmos-sdk#18477), so we need to
support custom genesis doc provider in this public API as well, it's
called by the `bootstrap-state` command in cosmos-sdk.

<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
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.

4 participants