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

polygon/p2p: retry fetch headers on response timeout #9537

Merged
merged 23 commits into from
Mar 4, 2024

Conversation

taratorio
Copy link
Member

No description provided.

Base automatically changed from astrid-p2p-chunk-fetch-headers to devel February 29, 2024 12:47
@taratorio taratorio marked this pull request as ready for review February 29, 2024 13:14
Copy link
Contributor

@battlmonstr battlmonstr left a comment

Choose a reason for hiding this comment

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

👍

@@ -26,6 +26,7 @@ require (
github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b
github.com/btcsuite/btcd/btcec/v2 v2.1.3
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b
github.com/cenkalti/backoff/v4 v4.2.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I've also implemented a simple generic retry in devnet request_generator.go. Maybe we can migrate it to this lib.

type RequestIdGenerator func() uint64

type FetcherConfig struct {
responseTimeout time.Duration
retryBackOff time.Duration
Copy link
Contributor

Choose a reason for hiding this comment

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

what does it mean? will it add retryBackOff for each subsequent request? e.g. retryBackOff=1 results in delays 1, 2, 3 (retries at t=1, t=3, t=6)?

Copy link
Member Author

Choose a reason for hiding this comment

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

we're using constant backoff retry mechanism which keeps the backoff the same, so request->fail->wait for 1 sec->request->fail->wait for 1 sec->request->fail->wait for 1 sec->request... and so on until max retries

the library has also the exponential backoff mechanism which is a bit more advanced (cam read about it in the docs)

Copy link
Contributor

Choose a reason for hiding this comment

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

👌 please check out my retry function in devnet request_generator.go, and we can discuss later which one we replace going forward

Copy link
Member Author

Choose a reason for hiding this comment

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

personally I'd use this open source library since it is a popular choice & less code for us to maintain if we were to have our own retry implementations

Copy link
Member Author

Choose a reason for hiding this comment

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

but no strong preference really - happy with either

Comment on lines +9 to 21
func NewChanMessageObserver[M any](ctx context.Context) ChanMessageObserver[M] {
return ChanMessageObserver[M]{
ctx: ctx,
channel: make(chan M),
}
}

type ChanMessageObserver[M any] struct {
ctx context.Context
channel chan M
}

func (cmo ChanMessageObserver[M]) Notify(msg M) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather pass ctx to Notify as parameter, because at the point of observer creation it might not be available yet.

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 tidy this up as part of the refactoring we discussed just now

@taratorio taratorio merged commit fe65bc8 into devel Mar 4, 2024
7 checks passed
@taratorio taratorio deleted the astrid-p2p-retry-fetch-headers-timeouts branch March 4, 2024 12:29
mriccobene pushed a commit to mriccobene/erigon that referenced this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants