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/stackerdb event observer #3870

Merged
merged 19 commits into from
Sep 1, 2023

Conversation

jcnelson
Copy link
Member

Address #3856. Event observers can subscribe to stacker DB events by listing the "stackerdb" event concern in their configs, or the "any" concern. StackerDBChunkEvent JSON objects will get pushed to /stackerdb_chunks for each successful chunk write (described in docs/event_observer.md).

@jcnelson jcnelson marked this pull request as ready for review August 22, 2023 21:51
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Merging #3870 (9480c71) into feat/stackerdb-rpc (20eec10) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@                  Coverage Diff                   @@
##           feat/stackerdb-rpc    #3870      +/-   ##
======================================================
- Coverage                0.16%    0.16%   -0.01%     
======================================================
  Files                     322      322              
  Lines                  287351   287640     +289     
======================================================
  Hits                      469      469              
- Misses                 286882   287171     +289     
Files Changed Coverage Δ
stackslib/src/net/mod.rs 0.00% <0.00%> (ø)
stackslib/src/net/relay.rs 0.00% <0.00%> (ø)
stackslib/src/net/rpc.rs 0.00% <0.00%> (ø)
stackslib/src/net/stackerdb/mod.rs 0.00% <ø> (ø)
stackslib/src/net/stackerdb/tests/sync.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/config.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/event_dispatcher.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/tests/neon_integrations.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/tests/stackerdb.rs 0.00% <0.00%> (ø)

📣 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.

LGTM -- just had a couple pretty superficial comments.

Comment on lines 297 to 301
fn new_stackerdb_chunks(
&self,
contract_id: &QualifiedContractIdentifier,
chunk_info: &[StackerDBChunkData],
);
Copy link
Member

Choose a reason for hiding this comment

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

Since both callers of this method consume their StackerDBChunkData instances anyways, this method could be consumptive, and then the event_dispatcher could avoid cloning this data:

Suggested change
fn new_stackerdb_chunks(
&self,
contract_id: &QualifiedContractIdentifier,
chunk_info: &[StackerDBChunkData],
);
fn new_stackerdb_chunks(
&self,
contract_id: QualifiedContractIdentifier,
chunk_info: Vec<StackerDBChunkData>,
);

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

.enumerate()
.filter(|(obs_id, _observer)| {
self.stackerdb_observers_lookup.contains(&(*obs_id as u16))
|| self.any_event_observers_lookup.contains(&(*obs_id as u16))
Copy link
Member

Choose a reason for hiding this comment

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

I'm inclined to say we shouldn't check the any_event_observers -- it's a pretty unfortunate interface, because it means that node configs aren't forwards-compatible: if you've configured an event observer with *, then the new endpoint is expected to be handled, but maybe you aren't handling it yet. I think the any_event_observer config option should be deprecated, but in the meantime, we shouldn't add new endpoints to it (I believe that this is how we've treated new event endpoints for a while).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@jcnelson jcnelson merged commit ef6c5a4 into feat/stackerdb-rpc Sep 1, 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.

4 participants