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 discovery #3552

Merged
merged 60 commits into from
Aug 11, 2023
Merged

Feat/stackerdb discovery #3552

merged 60 commits into from
Aug 11, 2023

Conversation

jcnelson
Copy link
Member

@jcnelson jcnelson commented Feb 5, 2023

This PR implements neighbor discovery for Stacker DB-aware Stacks nodes. Stacks nodes report to each other via StackerDBHandshakeAccept which DBs they replicate (stored to the LocalPeer table in PeerDB; ultimately will be set by the config file). Stacks nodes remember this information in the PeerDB as well, so that they can report which nodes replicate which DBs.

This PR also does some necessary refactoring work to the NeighborWalk state machine to separate out the low-level code for sending and receiving messages via the PeerNetwork from sending and reacting to messages. This will be used in a subsequent PR to simplify the implementation of the Stacker DB state replication logic.

…work into a NeighborSet trait, and make the NeighborWalk implement this trait. Use the trait methods for sending and receiving messages, so the NeighborWalk state machine can focus more on reacting to neighbors and less on the low-level socket implementation details. Also, expand the test framework so that even-port nodes are stackerdb-aware nodes, and odd-port nodes are not, and make it so each topology test verifies that all stackerdb-aware nodes learn of each others' dbs
@codecov
Copy link

codecov bot commented Feb 5, 2023

Codecov Report

Merging #3552 (6966f0c) into develop (c356b84) will decrease coverage by 0.01%.
Report is 1 commits behind head on develop.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #3552      +/-   ##
===========================================
- Coverage     0.16%    0.16%   -0.01%     
===========================================
  Files          305      310       +5     
  Lines       280694   281881    +1187     
===========================================
  Hits           469      469              
- Misses      280225   281412    +1187     
Files Changed Coverage Δ
stackslib/src/burnchains/bitcoin/indexer.rs 0.00% <0.00%> (ø)
stackslib/src/chainstate/coordinator/mod.rs 0.00% <0.00%> (ø)
stackslib/src/main.rs 0.00% <0.00%> (ø)
stackslib/src/net/chat.rs 0.00% <0.00%> (ø)
stackslib/src/net/connection.rs 0.00% <0.00%> (ø)
stackslib/src/net/db.rs 0.00% <0.00%> (ø)
stackslib/src/net/mod.rs 0.00% <0.00%> (ø)
stackslib/src/net/neighbors/comms.rs 0.00% <0.00%> (ø)
stackslib/src/net/neighbors/db.rs 0.00% <0.00%> (ø)
stackslib/src/net/neighbors/mod.rs 0.00% <0.00%> (ø)
... and 9 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.

Thanks for these changes and the clearer refactoring in the network code. I had a few comments throughout, but I think the stackerdb changes need more testing coverage -- does the included testing handle updating stackerdb entries, deletion of a peer, inserting a peer on an existing slot, etc? I think those behaviors need unit test coverage.

src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated
Ok(ret)
}

/// Get stacker DBs for a slot
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 that referring to what's returned here as "stacker dbs" is kind of confusing. My understanding is that this is "identifying the set of StackerDBs which are tracked by the peers stored in the frontier slots used_slots"

Copy link
Member

@kantai kantai Jul 24, 2023

Choose a reason for hiding this comment

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

Bump on this -- I think the usage of "stacker db" in the code currently is very confusing. It's being used ambiguously to refer both the data being tracked and the contract identifier of the contract governing that data. There are many places where a comment says something like "get stacker dbs for a slot" but it means something more like "get the ContractIDs whose associated databases are being tracked by the peers stored in the slots used_slots" (because a "slot" is actually itself a reference). The methods and fields in this file need better rustdocs.

src/net/db.rs Outdated Show resolved Hide resolved
src/net/neighbors.rs Outdated Show resolved Hide resolved
src/net/neighbors.rs Outdated Show resolved Hide resolved
src/net/neighbors.rs Outdated Show resolved Hide resolved
src/net/neighbors.rs Outdated Show resolved Hide resolved
src/net/neighbors.rs Outdated Show resolved Hide resolved
@kantai kantai mentioned this pull request Feb 10, 2023
@igorsyl igorsyl mentioned this pull request Feb 10, 2023
7 tasks
@pavitthrap pavitthrap added the frozen PRs that are on hold label Mar 21, 2023
@jcnelson jcnelson requested a review from kantai July 24, 2023 20:30
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.

There were a number of unaddressed comments from the spring, and I had a few more comments as well.

src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated
Ok(ret)
}

/// Get stacker DBs for a slot
Copy link
Member

@kantai kantai Jul 24, 2023

Choose a reason for hiding this comment

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

Bump on this -- I think the usage of "stacker db" in the code currently is very confusing. It's being used ambiguously to refer both the data being tracked and the contract identifier of the contract governing that data. There are many places where a comment says something like "get stacker dbs for a slot" but it means something more like "get the ContractIDs whose associated databases are being tracked by the peers stored in the slots used_slots" (because a "slot" is actually itself a reference). The methods and fields in this file need better rustdocs.

src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
src/net/db.rs Outdated Show resolved Hide resolved
@jcnelson
Copy link
Member Author

jcnelson commented Jul 24, 2023 via email

src/net/neighbors/mod.rs Outdated Show resolved Hide resolved
src/net/neighbors/mod.rs Outdated Show resolved Hide resolved
src/net/neighbors/db.rs Outdated Show resolved Hide resolved
@jcnelson
Copy link
Member Author

jcnelson commented Aug 3, 2023

Thanks for all the feedback @kantai! I've addressed all the points.

@jcnelson jcnelson requested a review from kantai August 3, 2023 04:03
@jcnelson jcnelson requested review from obycode and removed request for donpdonp August 3, 2023 20:34
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.

Thanks, LGTM!

Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

LGTM. I really like this refactoring! Just had a few very minor comments.


let indexer = BitcoinIndexer::new_unit_test(&self.config.burnchain.working_dir);
// let indexer = BitcoinIndexer::new_unit_test(&self.config.burnchain.working_dir);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup!

impl ToNeighborKey for NeighborAddress {
fn to_neighbor_key(&self, network: &PeerNetwork) -> NeighborKey {
// NOTE: PartialEq and Hash for NeighborKey ignore the low bits of peer version
// and ignore network ID, and the CovnersationP2P ensures that we never even connect
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
// and ignore network ID, and the CovnersationP2P ensures that we never even connect
// and ignore network ID, and the ConversationP2P ensures that we never even connect

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

}

impl NeighborWalkDB for PeerDBNeighborWalk {
/// implements get_fresh_random_neighbors
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these "implements ..." comments really helpful? Are they just meant to be placeholders?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will remove -- they're an artifact from an earlier version of this code

@jcnelson jcnelson merged commit 382cb80 into develop Aug 11, 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
frozen PRs that are on hold locked sbtc
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

6 participants