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

feat: allow ignoring PublishError.Duplicate #404

Merged
merged 7 commits into from
Feb 21, 2023

Conversation

maschad
Copy link
Contributor

@maschad maschad commented Feb 14, 2023

Closes #402

When ignoreDuplicatePublishError is set, instead of throwing with PublishError.Duplicate, simply return.

@maschad maschad requested a review from a team as a code owner February 14, 2023 21:42
@maschad maschad changed the title feat: allow for duplicate messages (#402) feat: allow for duplicate messages Feb 14, 2023
src/index.ts Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2023

Codecov Report

Base: 83.41% // Head: 83.31% // Decreases project coverage by -0.11% ⚠️

Coverage data is based on head (5906a27) compared to base (41740b5).
Patch coverage: 76.69% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #404      +/-   ##
==========================================
- Coverage   83.41%   83.31%   -0.11%     
==========================================
  Files          48       48              
  Lines       11766    11800      +34     
  Branches     1266     1271       +5     
==========================================
+ Hits         9815     9831      +16     
- Misses       1951     1969      +18     
Impacted Files Coverage Δ
src/metrics.ts 21.25% <0.00%> (-0.51%) ⬇️
src/index.ts 70.46% <80.00%> (+0.02%) ⬆️
src/score/peer-score-params.ts 98.21% <91.42%> (+0.75%) ⬆️
src/score/peer-score-thresholds.ts 100.00% <100.00%> (ø)
src/types.ts 94.57% <100.00%> (+0.16%) ⬆️
test/gossip.spec.ts 96.62% <100.00%> (+0.26%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@maschad maschad requested a review from twoeths February 15, 2023 20:20
@maschad
Copy link
Contributor Author

maschad commented Feb 15, 2023

Looks like @dapplion had raised a similar issue #272

He also suggested that we could add an array of topics to the signature, what do you think @tuyennhv ?

src/metrics.ts Outdated Show resolved Hide resolved
src/metrics.ts Outdated Show resolved Hide resolved
@twoeths
Copy link
Contributor

twoeths commented Feb 16, 2023

Looks like @dapplion had raised a similar issue #272

He also suggested that we could add an array of topics to the signature, what do you think @tuyennhv ?

I'm not clear about the context in that issue, if we publish same message to multiple topics, we also need to modify the fastMsgIdFn for the received side. Also we can just call publish() multiple times with same message and different topics.

@dapplion do we need an array of topics or just an option to ignore duplicate check is enough?

@what-the-diff
Copy link

what-the-diff bot commented Feb 16, 2023

  • Added a new option to ignore duplicate messages
  • Updated the metrics for ignoring duplicates

@maschad
Copy link
Contributor Author

maschad commented Feb 16, 2023

Thanks for reviewing @tuyennhv I have made the requested updates. I think we could probably address #272 in a separate PR since the issue was raised in a different context.

@maschad maschad requested a review from twoeths February 16, 2023 15:27
@maschad maschad mentioned this pull request Feb 16, 2023
dapplion
dapplion previously approved these changes Feb 19, 2023
twoeths
twoeths previously approved these changes Feb 20, 2023
@wemeetagain wemeetagain changed the title feat: allow for duplicate messages feat: allow publish of duplicate messages Feb 20, 2023
src/index.ts Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/metrics.ts Outdated Show resolved Hide resolved
@wemeetagain wemeetagain dismissed stale reviews from twoeths and dapplion via 68c897b February 20, 2023 02:33
src/types.ts Outdated Show resolved Hide resolved
@wemeetagain
Copy link
Member

wemeetagain commented Feb 20, 2023

  • Added a new option to ignore duplicate messages
  • Updated the metrics for ignoring duplicates

This isn't right. -1 for the AI
Messages aren't being ignored. The metric isn't tracking ignored duplicates.
This feature allows us to publish duplicate messages. The metric tracks the number of published duplicates.
Edit: This feature allows us to avoid throwing an error when publishing a duplicate message. The metric tracks the number of duplicate message publish attempts.

if (this.seenCache.has(msgIdStr)) {
// This message has already been seen. We don't re-publish messages that have already
// been published on the network.
if (allowPublishDuplicateMessages) {
this.metrics?.onPublishDuplicateMsg(topic)
return { recipients: [] }
Copy link
Member

Choose a reason for hiding this comment

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

@tuyennhv correct me if i'm wrong, this isn't what we want?
I thought we want to actually follow the same flow and actually send messages to peers?

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case some other nodes already published this same message and it's around in the topic peers already, I found it's not helpful to send to topic peers again - some nodes already saw that message and sent it to us, they may already had it in their seen cache too.

In lodestar's scenario, builder published the block, then the node receives the message and try to publish again and it throws error. The published block was spread to the network successfully, only our api throws error.

@maschad
Copy link
Contributor Author

maschad commented Feb 20, 2023

  • Added a new option to ignore duplicate messages
  • Updated the metrics for ignoring duplicates

This isn't right. -1 for the AI Messages aren't being ignored. The metric isn't tracking ignored duplicates. This feature allows us to publish duplicate messages. The metric tracks the number of published duplicates. Edit: This feature allows us to avoid throwing an error when publishing a duplicate message. The metric tracks the number of duplicate message publish attempts.

Technically it was correct because we where returning early / an empty message which was the original intention in #402 i.e. option to publish api to return early and ignore the error

As @tuyennhv mentioned it's not helpful to republish to those peers again since some nodes already would've seen that message, thus they may have already had it in their seen cache too.

So with that in mind I posit that ignoreDuplicateMessages may be a more appropriate name as opposed to allowPublishDuplicateMessages

@wemeetagain
Copy link
Member

Reason I'm not a fan of "ignoreDuplicateMessages" naming is that its too general and the terms feel overloaded.
We "ignore" messages in gossip validation, though this feature has nothing to do with this kind of ignoring. We also have two message flows (publish and forward) that handle duplicate messages, so "ignoreDuplicateMessages" sounds like a blanket statement about how we handle duplicate messages.

"allowPublishDuplicateMessage" follows the naming of the other "suppress a publish error" option - "allowPublishToZeroPeers" - generally "allowPublishErrorname".
Do agree there's some confusion in this naming as well tho.

Imo the core feature here is suppressing / avoiding a publish error. Probably there's some other name that can clearly articulate this.

@maschad
Copy link
Contributor Author

maschad commented Feb 20, 2023

Understood. I think ignoreDuplicatePublishError captures the essence of conveying that we are trying to avoid a publish error then.

@wemeetagain wemeetagain changed the title feat: allow publish of duplicate messages feat: allow ignoring PublishError.Duplicate Feb 20, 2023
@wemeetagain wemeetagain merged commit dcde3c9 into ChainSafe:master Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New option for publish api to ignore duplicate
5 participants