-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Only Sync With the Peer With the Highest Observed Slot #2280
Conversation
@@ -268,24 +274,6 @@ func (s *InitialSync) checkInMemoryBlocks() { | |||
} | |||
} | |||
|
|||
// listenForNewBlocks listens for block announcements beyond the canonical head slot that may |
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.
No longer relevant as this is handled by regular sync
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 still should have it, otherwise the node will always have to play catch up whenever it starts regular sync
Build and lint errors |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Build and test failing |
Test failures |
Codecov Report
@@ Coverage Diff @@
## master #2280 +/- ##
==========================================
- Coverage 66.6% 65.19% -1.41%
==========================================
Files 119 119
Lines 9642 9533 -109
==========================================
- Hits 6422 6215 -207
- Misses 2503 2627 +124
+ Partials 717 691 -26 |
@@ -17,6 +17,8 @@ import ( | |||
"sync" | |||
"time" | |||
|
|||
peer "github.com/libp2p/go-libp2p-peer" | |||
|
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.
Space
beacon-chain/sync/querier.go
Outdated
@@ -5,6 +5,8 @@ import ( | |||
"math/big" | |||
"time" | |||
|
|||
peer "github.com/libp2p/go-libp2p-peer" | |||
|
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.
Space
beacon-chain/sync/regular_sync.go
Outdated
@@ -8,6 +8,8 @@ import ( | |||
"runtime/debug" | |||
"sync" | |||
|
|||
peer "github.com/libp2p/go-libp2p-peer" | |||
|
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.
Space
shared/p2p/service.go
Outdated
@@ -184,6 +184,11 @@ func (s *Server) Status() error { | |||
return nil | |||
} | |||
|
|||
// Peers returns a slice of currently connected peer id's to be used throughout the runtime. | |||
func (s *Server) Peers() peer.IDSlice { | |||
return s.host.Peerstore().Peers() |
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.
Use s.host.Network().Peers()
PTAL @prestonvanloon |
@@ -268,24 +274,6 @@ func (s *InitialSync) checkInMemoryBlocks() { | |||
} | |||
} | |||
|
|||
// listenForNewBlocks listens for block announcements beyond the canonical head slot that may |
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 still should have it, otherwise the node will always have to play catch up whenever it starts regular sync
@@ -96,11 +97,11 @@ func (s *InitialSync) processState(msg p2p.Message) { | |||
} | |||
|
|||
// requestStateFromPeer requests for the canonical state, finalized state, and justified state from a peer. | |||
func (s *InitialSync) requestStateFromPeer(ctx context.Context, lastFinalizedRoot [32]byte) error { | |||
func (s *InitialSync) requestStateFromPeer(ctx context.Context, lastFinalizedRoot [32]byte, peerID peer.ID) error { |
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.
you should just use s.bestPeer here, since we are only going to sync with one peer
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.
Minor comments. Overall LGTM.
This is a great interim solution until we rethink the sync logic with the weak subjectivity logic.
Thanks!
if msg.Peer != s.bestPeer { | ||
// Only process batch block responses that come from the best peer | ||
// we originally synced with. | ||
log.Debugf("Received batch blocks from a different peer: %s", msg.Peer.Pretty()) |
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.
Use WithField
beacon-chain/sync/querier.go
Outdated
case msg := <-q.responseBuf: | ||
response := msg.Data.(*pb.ChainHeadResponse) | ||
case <-timeout: | ||
queryLog.Infof("Peer with highest canonical head: %v", q.bestPeer.Pretty()) |
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.
These should conform to WithFields logging standard, please
// RequestLatestHead broadcasts out a request for all | ||
// the latest chain heads from the node's peers. | ||
// RequestLatestHead sends a request for all | ||
// the latest chain head slot and state root to a peer. |
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.
Do you want to change this comment back? It’s still broadcasting
You have new lint issues
|
This is part of #1586
Description
Write why you are making the changes in this pull request
Currently, our chain head querier naively accepts any response it gets, even though it might be from a peer that is really far behind or forked. Instead, we should query all peers and use the highest one as our reference to sync with the network.
Where it requests the latest heads from all peers and only exits after a timeout. It then goes with the peer that has the highest canonical slot.