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

Add a periodic chain re-broadcast mechanism #840

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

masih
Copy link
Member

@masih masih commented Jan 21, 2025

Based on a configured rebroadcast interval periodically rebroadcast the longest chain currently being progressed by GPBFT.

Extend the chain exchange broadcast message to include a timestamp rounded down to the rebroadcast interval as a way to work around gossipsub deduplication. This is to help gain better message propagation.

The rebroadcast interval is reset as soon as the first message with a larger instance is observed, signaling the start of the next instance. This helps synchronize the chain rebroadcast intervals relative to the GPBFT instance start.

Fixes #814

Based on a configured rebroadcast interval periodically rebroadcast the
longest chain currently being progressed by GPBFT.

Extend the chain exchange broadcast message to include a timestamp
rounded down to the rebroadcast interval as a way to work around
gossipsub deduplication. This is to help gain better message
propagation.

The rebroadcast interval is reset as soon as the first message with a
larger instance is observed, signaling the start of the next instance.
This helps synchronize the chain rebroadcast intervals relative to the
GPBFT instance start.

Fixes #814
@masih masih self-assigned this Jan 21, 2025
@masih masih requested a review from Kubuxu January 21, 2025 21:23
@masih masih added this to the M2: Mainnet Passive Testing milestone Jan 21, 2025
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 65.88235% with 29 lines in your changes missing coverage. Please review.

Project coverage is 67.17%. Comparing base (9c11ba3) to head (5743df4).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
partial_msg.go 68.42% 15 Missing and 3 partials ⚠️
gpbft/chain.go 50.00% 4 Missing and 2 partials ⚠️
chainexchange/options.go 57.14% 2 Missing and 1 partial ⚠️
manifest/manifest.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #840      +/-   ##
==========================================
- Coverage   67.39%   67.17%   -0.23%     
==========================================
  Files          84       84              
  Lines        8915     8995      +80     
==========================================
+ Hits         6008     6042      +34     
- Misses       2380     2419      +39     
- Partials      527      534       +7     
Files with missing lines Coverage Δ
chainexchange/chainexchange.go 100.00% <ø> (ø)
chainexchange/pubsub.go 72.76% <100.00%> (-5.31%) ⬇️
manifest/manifest.go 50.00% <0.00%> (-0.53%) ⬇️
chainexchange/options.go 59.37% <57.14%> (-0.18%) ⬇️
gpbft/chain.go 87.96% <50.00%> (-2.24%) ⬇️
partial_msg.go 63.21% <68.42%> (+0.53%) ⬆️

... and 5 files with indirect coverage changes

if err := pmm.chainex.Broadcast(ctx, *current); err != nil {
log.Errorw("Failed to immediately re-broadcast chain.", "instance", current.Instance, "chain", current.Chain, "error", err)
}
ticker.Reset(pmm.rebroadcastInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set the ticker to the rounded down time + interval instead, to line it up?
I don't think it matters; it just came up while I was reviewing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup that makes sense. Thanks Kuba

Copy link
Member 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 this makes sense for the first firing of ticker but after that we want to use the interval. Right?

This makes the code complicated enough such that it puts me off from doing it. With the default interval of 2 seconds (and most likely sub 10s in any case?) I think it's not worth it.

Going to merge as is. Please let me know if you think otherwise and I will adjust in a follow up PR 🙏

@masih masih added this pull request to the merge queue Jan 23, 2025
Merged via the queue into main with commit 5c916d1 Jan 23, 2025
14 checks passed
@masih masih deleted the masih/chainex-rebroadcast branch January 23, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement a chain rebroadcast mechanism independent of GPBFT
2 participants