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

Feat/stacks signer #3850

Merged
merged 82 commits into from
Sep 21, 2023
Merged

Feat/stacks signer #3850

merged 82 commits into from
Sep 21, 2023

Conversation

jcnelson
Copy link
Member

@jcnelson jcnelson commented Aug 18, 2023

This PR adds in the event observer system for StackerDB chunk arrivals, and adds a libsigner crate which consumes them and feeds them into a signer-specific runloop. StackerDB events contain the chunk data, so downstream consumers do not need to go and pull them.

libsigner is a basic crate that just implements an event observer client for StackerDB messages, and a means of passing them into an implementation-specific runloop body. See the unit test in libsigner/src/tests/mod.rs for example usage.

@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Merging #3850 (904c7ab) into develop (5ca6fd2) will decrease coverage by 0.01%.
Report is 1 commits behind head on develop.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #3850      +/-   ##
===========================================
- Coverage     0.16%    0.16%   -0.01%     
===========================================
  Files          322      339      +17     
  Lines       287661   290230    +2569     
===========================================
  Hits           469      469              
- Misses      287192   289761    +2569     
Files Changed Coverage Δ
libsigner/src/error.rs 0.00% <0.00%> (ø)
libsigner/src/events.rs 0.00% <0.00%> (ø)
libsigner/src/http.rs 0.00% <0.00%> (ø)
libsigner/src/runloop.rs 0.00% <0.00%> (ø)
libsigner/src/session.rs 0.00% <0.00%> (ø)
libsigner/src/tests/http.rs 0.00% <0.00%> (ø)
libsigner/src/tests/mod.rs 0.00% <0.00%> (ø)
libstackerdb/src/libstackerdb.rs 0.00% <ø> (ø)
stacks-common/src/deps_common/ctrlc/error.rs 0.00% <ø> (ø)
stacks-common/src/deps_common/ctrlc/mod.rs 0.00% <ø> (ø)
... and 23 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

The stacks signer seems like it could use a request library like ureq or reqwest rather than implementing a new HTTP client.

@jcnelson
Copy link
Member Author

The stacks signer seems like it could use a request library like ureq or reqwest rather than implementing a new HTTP client.

Sure; I just added a really simple one for testing / debugging purposes. The stacker-signer will code to the trait, not this particular implementation.

@jcnelson jcnelson changed the base branch from feat/stackerdb-rpc to feat/stackerdb-event-observer August 23, 2023 01:27
@jcnelson jcnelson marked this pull request as ready for review August 28, 2023 15:46
jferrant and others added 18 commits September 15, 2023 15:31
Signed-off-by: Jacinta Ferrant <[email protected]>
…s interested; remove sleep calls in test since we know when it's done
Signed-off-by: Jacinta Ferrant <[email protected]>
Signed-off-by: Jacinta Ferrant <[email protected]>
@jcnelson
Copy link
Member Author

@kantai @stjepangolemac @xoloki @jferrant There are a few PRs that are blocked on this PR. Can we merge this to develop? It's becoming a staging ground for a bunch of signer PRs that really should be hitting develop. Thanks!

Copy link
Collaborator

@xoloki xoloki left a comment

Choose a reason for hiding this comment

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

Looks good! My only real comment is that it would be great to remove as much custom HTTP code as possible, since we're using tiny_http internally now in libsigner. But I'd be happy if this all went in as-is.

I can also submit upstream PRs to tiny_http to remove any unsafe code there. I'd good at playing the open source game ;)


/// Decoding of the relevant parts of a signer-directed HTTP request from the Stacks node
#[derive(Debug)]
pub struct SignerHttpRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're using tiny_http now, probably all of this can go away.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did that happen in an upstream PR? Or is this just now dead code?

Either way, would it make sense to first merge the PR that includes tiny_http into this PR first, and then merge this PR with tiny_http applied?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This happened in the first Signer PR:

https://github.com/stacks-network/stacks-blockchain/blob/feat/stacks-signer/libsigner/Cargo.toml#L29
https://github.com/stacks-network/stacks-blockchain/blob/feat/stacks-signer/libsigner/src/events.rs#L33
https://github.com/stacks-network/stacks-blockchain/blob/feat/stacks-signer/libsigner/src/events.rs#L201

We're currently using it as an HTTP server for StackerDBEventReceiver. So all of the server side HTTP parsing can go away in libsigner, since tiny_http comes with its own parser and request/response objects, along with all the tests.

In a later PR we can explore getting rid of async_h1, which is used for the client side of the stacks event observer code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So AFAICT all of the libsigner custom HTTP code is now dead.

Copy link
Collaborator

@jferrant jferrant Sep 21, 2023

Choose a reason for hiding this comment

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

Lines 33 through 127 are dead. However, we do use the run_http_request code (rpc_request is used throughout SignerSession which in turn uses run_http_request and a few other of the functions here)


use stacks_common::util::chunked_encoding::*;

#[test]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can also probably all go away since we're using tiny_http

Copy link
Collaborator

Choose a reason for hiding this comment

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

Lines 29 through 101 can but until we update SignerSession, we can't get rid of the rest.

Copy link
Contributor

@stjepangolemac stjepangolemac left a comment

Choose a reason for hiding this comment

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

I haven't seen anything obviously wrong or weird, but the PR is large so take this with a grain of salt.

Copy link
Collaborator

@jferrant jferrant left a comment

Choose a reason for hiding this comment

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

Aside from potentially deleting the portions of dead HTTP code, might want to make a ticket to fully remove it from SignerSession and to use tiny http instead. Aside from that would just merge and build smaller PRs off of Develop.

So TLDR. LGTM

@jcnelson jcnelson merged commit 7361ab4 into develop Sep 21, 2023
1 check passed
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants