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
[Refactor] HTTP RPC System Refactor #3987
Conversation
…f re-opening a StacksChainState)
…rposes of reopening it)
…nsaction streaming code
…ndpoint, without destroying the write endpoint. This lets the caller send data to the read endpoint as it's being generated, so the read endpoint can consume it concurrently.
First pass done. All my comments have to do with just readability/syntax. Didn't see anything functionally wrong, but I will do another pass on monday! |
@jcnelson I assume you want something like: It compiles for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to run tests::signer::test_stackerdb_dkg
, it never completes. I have no idea what's happening but the logs are spamming very fast.
Get this test running, then try it with num_keys = 4000
(testnet/stacks-node/src/tests/signer.rs:161
). If DKG takes longer than ~90sec, or either of the sign operations takes longer than ~100sec, something is badly wrong with the HTTP layer and it's effectively breaking stackerDB under load.
Thanks @xoloki! The bug was that the new handler uploading StackerDB chunks was not forwarding the chunk data to the relayer. This, in turn, prevented any StackerDB events from propagating to the signer. I noticed that |
Thanks @jcnelson! Glad it was a quick fix, and that we're putting the dkg test into CI.
Can you change the number of signers/keys at Get that done and I'll approve this PR. |
The DKG test would only run on release CI, so added time isn't too much of a concern for day-to-day tests. I went ahead and used 100 signers and 4000 keys. If this somehow fails release CI due to a timeout, I can bump it back to 4 signers and 100 keys. Does that work for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks so much for the quick fix and CI inclusion!
Keep in mind that there will be multiple threads per signer, and depending on the OS and hardware hundreds of threads might run poorly. But either way I'm happy. |
… anyway, so it's fine if it takes a while.
Alright folks, here it is: The Big HTTP RPC Refactor.
This PR achieves two things: it separates HTTP transport concerns from RPC business logic, and it refactors the RPC system so that each RPC method's business logic can live entirely in its own file. You can find them all under
stackslib/src/net/api
.The bulk of the delta here is composed:
stackslib/src/net/http.rs
into the new modulestackslib/src/net/http
stackslib/src/net/rpc.rs
intostackslib/src/net/api
stackslib/src/net/mod.rs
intostackslib/src/net/httpcore.rs
.The first change sets the stage for fully removing HTTP transport concerns from
stackslib
, and putting them into their own top-level crate. The code in this module does not depend on any Stacks-specific code or data. The second change effectively isolates the RPC functions from the rest of the system, and exposes various Stacks node state under a newStacksNodeState
struct (which can gain new members and functions as we need them). The third change binds the newly-isolated HTTP transport code instackslib/src/net/http
to the Stacks blockchain, and implements a high-level HTTP state machine atopnet::connection::ProtocolFamily<P>
to be used bynet::server::ConversationHttp
to manage client connection lifecycles.As you can see from the individual RPC methods, one only needs to implement the
net::http::HttpRequest
,net::http::HttpResponse
, andnet::httpcore::RPCRequestHandler
traits for a given struct in order to implement a new RPC method. Once this is done, it can be registered with theStacksHttp
state machine with a call toregister_rpc_endpoint()
insrc/net/api/mod.rs
.In a hopeless bid to keep this PR smaller than it could have been, I have opted to keep
net::http
andnet::connection.rs
withinstackslib
for now. However, I fully expect to move these both into top-level crates, and possibly move the chunked transfer encoding andPeerAddress
/PeerHost
types out ofstacks_common
and into one of these crates. But that is for another day.