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

ADR-14: bootstrap from previously seen peers #2024

Closed

Conversation

derrandz
Copy link
Contributor

@derrandz derrandz commented Apr 5, 2023

Overview

Self-explanatory, closes #1851

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2023

Codecov Report

Merging #2024 (c8cd4da) into main (952a93e) will increase coverage by 1.22%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2024      +/-   ##
==========================================
+ Coverage   54.19%   55.41%   +1.22%     
==========================================
  Files         217      209       -8     
  Lines       14031    13324     -707     
==========================================
- Hits         7604     7384     -220     
+ Misses       5600     5194     -406     
+ Partials      827      746      -81     
Impacted Files Coverage Δ
nodebuilder/header/flags.go 48.00% <100.00%> (ø)

... and 71 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

Submitting partial review, ended right before Peer Selection section

docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved

### Database

We will use a badgerDB datastore to store the addresses of previously seen peers. The database will be stored in the `data` directory, and will be named `peers.db`. The database will have a single key-value pair, where the key is the peer ID, and the value is the peer multiaddress.
Copy link
Member

Choose a reason for hiding this comment

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

My suggestion is to check out the checkpointStore implementation inside of the daser because the on-disk peerstore will look similar (a prefixed-store + a single key where the value is the "good peers").

docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
@derrandz derrandz self-assigned this Apr 5, 2023
@derrandz derrandz added the kind:docs For solely documentation PRs label Apr 5, 2023
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
+ p.onBlockedPeer(PIDToAddrInfo(pID))
}
```
We are assuming a function named `PIDToAddrInfo` that converts a `peer.ID` to a `peer.AddrInfo` struct for this example's purpose.
Copy link
Member

Choose a reason for hiding this comment

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

host.Peerstore().PeerInfo(id)

docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-013-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
@derrandz derrandz force-pushed the adr/bootstrap-from-previous-peers branch from 2f38ded to 91682c8 Compare April 6, 2023 16:07
@derrandz derrandz changed the title ADR: bootstrap from previously seen peers ADR-14: bootstrap from previously seen peers Apr 11, 2023
Copy link
Collaborator

@distractedm1nd distractedm1nd left a comment

Choose a reason for hiding this comment

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

first scan

docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

My only suggestion is to decrease the amount of code snippets you include for approach A

I think the most important thing is to outline where the hooks will be passed, why they occur inside peer tracker, and what the actual hooks will look like themselves. The other stuff is unnecessary and distracting - it'll also probably look different in the implementation. The idea here is just to outline how it'd be integrated.

ideally this ADR could also exist inside go-header somehow if we decide to go with approach A :)

docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
@derrandz derrandz force-pushed the adr/bootstrap-from-previous-peers branch from bbb2f84 to 670fe64 Compare April 14, 2023 15:17
distractedm1nd
distractedm1nd previously approved these changes Apr 17, 2023
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

Requesting subtle changes for Approach A. Overall, I like the way the doc is structured and written.

docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
@derrandz derrandz force-pushed the adr/bootstrap-from-previous-peers branch from 52701cf to c8cd4da Compare April 25, 2023 17:18
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
docs/adr/adr-014-bootstrap-from-previous-peers.md Outdated Show resolved Hide resolved
Comment on lines +58 to +63
type PeerStore interface {
// Put adds a list of peers to the store.
Put([]peer.AddrInfo) error
// Get returns a peer from the store.
Load() ([]peer.AddrInfo, error)
}
Copy link
Member

Choose a reason for hiding this comment

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

There is no need for interface, if there is only one implementation planned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In implementation yes, but in ADR I think an interface is eloquent and transmits the message clearly

// chainID is an identifier of the chain.
chainID string
+
+ peerstore Peerstore
Copy link
Member

Choose a reason for hiding this comment

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

It seems unusual to pass dependancy object by Params. Is there particular reason for it, or it is just a draft, that will be changed when actual implementation will be create?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is odd indeed, but we want this dependency to be optional and given the current signature, we got to do it this way. The implementation is in celestiaorg/go-header#36 please give it a review

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, I think it shouldn't be a param.
cc @renaynay @Wondertan

+ peerset = ex.trustedPeers
+ } else {
+ // otherwise, node has a chain head that is NOT outdated so we can actually request random peers in addition to trusted
+ peerset = append(ex.trustedPeers, ex.params.peerstore.Get())
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense on Put operation to store additional time.Now value and check the time passed since last store operation on Load, to identify if stored information is likely to be outdate and should be ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I think yes.

fix: implement latest requested changes
@derrandz derrandz force-pushed the adr/bootstrap-from-previous-peers branch from 932f6c9 to bf5d30d Compare May 11, 2023 13:16
@renaynay
Copy link
Member

Closing this in favour of a doc on go-header instead as the solution is almost fully contained to that repo

@renaynay renaynay closed this Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:adr kind:docs For solely documentation PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Persist peers to disk such that nodes can bootstrap from previously seen peers
7 participants