-
Notifications
You must be signed in to change notification settings - Fork 251
feat: ensure p2p DAHint within limits #3128
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -625,9 +625,40 @@ func (s *Syncer) processHeightEvent(ctx context.Context, event *common.DAHeightE | |
| } | ||
| } | ||
| if len(daHeightHints) > 0 { | ||
| currentDAHeight := s.daRetrieverHeight.Load() | ||
|
|
||
| // Only fetch the latest DA height if any hint is suspiciously far ahead. | ||
| const daHintMaxDrift = uint64(200) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an arbitrary value to ensure that we do not hit DA height request on every message |
||
| needsValidation := false | ||
| for _, h := range daHeightHints { | ||
| if h > currentDAHeight+daHintMaxDrift { | ||
| needsValidation = true | ||
| break | ||
| } | ||
| } | ||
|
|
||
| var latestDAHeight uint64 | ||
| if needsValidation { | ||
| var err error | ||
| xCtx, cancel := context.WithTimeout(ctx, 500*time.Millisecond) | ||
| latestDAHeight, err = s.daClient.GetLatestDAHeight(xCtx) | ||
| cancel() | ||
| if err != nil { | ||
| s.logger.Warn().Err(err).Msg("failed to fetch latest DA height") | ||
| needsValidation = false // ignore error as height is checked in the daRetriever | ||
| } | ||
| } | ||
|
|
||
| for _, daHeightHint := range daHeightHints { | ||
| // Skip if we've already fetched past this height | ||
| if daHeightHint < s.daRetrieverHeight.Load() { | ||
| if daHeightHint < currentDAHeight { | ||
| continue | ||
| } | ||
|
|
||
| if needsValidation && daHeightHint > latestDAHeight { | ||
| s.logger.Warn().Uint64("da_height_hint", daHeightHint). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be really noisy during syncing, when we are receiving p2p blocks very far ahead. |
||
| Uint64("latest_da_height", latestDAHeight). | ||
| Msg("ignoring unreasonable DA height hint from P2P") | ||
| continue | ||
| } | ||
|
|
||
|
|
||
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.
Fix spacing before period.
There's an extra space before the period in "catchup ." — it should be "catchup."
✏️ Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~29-~29: Ensure spelling is correct
Context: ...malicious peers from triggering runaway catchup . [
#3128](https://github.com/evstack/ev...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents