-
Notifications
You must be signed in to change notification settings - Fork 760
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
Client: New Mechanism to Keep Peer Latest Block Updated #3354
Client: New Mechanism to Keep Peer Latest Block Updated #3354
Conversation
cb049b2
to
4d42c1a
Compare
Yeah, ok, I think this should basically do the job! 🙂 Took me several iterations to get this a bit to the point, the base implementation is now pretty clean I would say. So a more differentiated request on the latest/best block by a peer is now directly integrated into the The peer remembers the last block from the best block request, on first round this is the block from On second round onwards, a request is done either towards a block number from This logic should work both pre and post merge. I only tested this pre-merge on mainnet, this is then actually the first time we have something like a constant sync target height update on mainnet (since the Two caveats remain:
|
} else if (protocol.name === 'les') { | ||
this.les = <BoundLesProtocol>bound | ||
} else { | ||
throw new Error(`addProtocol: ${protocol.name} protocol not supported`) | ||
} |
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.
This looks wild but is only a small local refactor making things a bit cleaner. 🙂
p.idle = true | ||
} | ||
} | ||
} |
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 generally would think it would make more sense to have all (or: most, so except for the first one) latest()
updates being triggered from here. Atm this is not very effective though, since we can only call on idle peers (see reasoning in separate comment) and mostly peers are not idle and so this is not getting called on peers very often in the current status quo.
8ea54b6
to
877bafa
Compare
…ly on protocol binding, small local refactor
…sendStatus for devp2p protocols
…to move from Sync -> Peer
…atest() call on peers in peer pool
877bafa
to
d6c2a6c
Compare
…m-to-redo-peer-handshake-for-status-update
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
…e-for-status-update
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.
lgtm
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.
Got one question, LGTM in general
const bestHeaderNum = this.eth!.updatedBestHeader.number | ||
const nowSec = Math.floor(Date.now() / 1000) | ||
const diffSec = nowSec - Number(this.eth!.updatedBestHeader.timestamp) | ||
const SLOT_TIME = 12 |
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.
What if a slot is missed? Then this block is definitely not there 🤔
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.
Good point, I initially planned to do 2-3 more commits fine tuning the existing solution a bit with a somewhat more adaptive algorithm (basically remember the last unsuccessful try (or remove on success again) and if present then gradually downgrade the request (so: try a lower block number)).
Guess we likely can/want to do this in a small follow-up PR, should be not such a big effort.
This PR adds a periodical check if the ETH status message exchanged by peers in the client is getting too old for then triggering a new handshake which should (theoretically) update the status information.Not yet working, will continue tomorrow. Feedback welcome!Initial description outdated, see updated post below