-
Notifications
You must be signed in to change notification settings - Fork 33
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
[P2P] KISS 4 - Basic nodes bootstrapping [Merge me after #522] - (Issue: #498) #523
Conversation
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
p2p/event_handler.go
Outdated
} | ||
} | ||
if !isSelfInAddrBook(m.address, addrBook) { | ||
m.logger.Warn().Msg("Self address not found in addresbook, advertising") |
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.
https://github.com/pokt-network/pocket/pull/491/files#r1108018541
WHy do we only advertise if we're not in the address book?
Good question. It's because the nodes are created with a genesis and if you are node 005+ you have the first 4 but not self. It's something we need to figure out.
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.
- We might end up moving the addr book bootstrapping to a config file rather than genesis.
- Unrelated to (1), there's no harm to advertise even if some part of the network is already aware of your existence
p.logger.Info().Bool("TODO", true).Msg("Advertise self to network")
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.
Agreed
…k/pocket into issue/498-kiss-bootstrapping
p2p/module.go
Outdated
func isValidHostnamePort(str string) bool { | ||
pattern := regexp.MustCompile(`^(https?)://([a-zA-Z0-9.-]+):(\d{1,5})$`) | ||
matches := pattern.FindStringSubmatch(str) | ||
if len(matches) != 4 { |
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.
if len(matches) != 4 { | |
if matches != nil || len(matches) != 4 { |
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.
I think it's redundant since the nil
case in included in "not len(4)"
nill := []string(nil)
if len(nill) != 4 {
fmt.Println("not 4")
}
Prints not 4
p2p/module.go
Outdated
if len(matches) != 4 { | ||
return false | ||
} | ||
protocol := matches[1] |
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.
It's not zero indexisble?
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.
the 0th index is the (outermost) group that matches the whole regex
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.
More context:
https://pkg.go.dev/regexp#Regexp.FindStringSubmatch
If 'Submatch' is present, the return value is a slice identifying the successive submatches of the expression. Submatches are matches of parenthesized subexpressions (also known as capturing groups) within the regular expression, numbered from left to right in order of opening parenthesis. Submatch 0 is the match of the entire expression, submatch 1 is the match of the first parenthesized subexpression, and so on.
…strapping Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
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.
A few minor comments (see them as optional), but otherwise, lgtm. A good way to end off a Monday after Valentine's week ;)
Description
This PR has been extracted from #491 and is, hopefully, more digestible from a code-review and scope point of view.
This simply adds entrypoints and basic logic for node bootstrapping leveraging the finite state machine
Issue
Fixes #498
Type of change
Please mark the relevant option(s):
List of changes
Testing
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)