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

Deduplicate triggers #4055

Merged
merged 6 commits into from
Nov 8, 2022
Merged

Deduplicate triggers #4055

merged 6 commits into from
Nov 8, 2022

Conversation

evaporei
Copy link
Contributor

No description provided.

@evaporei evaporei self-assigned this Oct 11, 2022
@evaporei evaporei changed the title Deduplicate triggerw Deduplicate triggers Oct 11, 2022
@@ -173,9 +173,22 @@ where
}

impl<C: Blockchain> BlockWithTriggers<C> {
pub fn new(block: C::Block, mut trigger_data: Vec<C::TriggerData>) -> Self {
pub fn new(block: C::Block, mut trigger_data: Vec<C::TriggerData>, logger: &Logger) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

This to me sounds like a lot of logic for a new function. I'd rather change this to something from_trigger_data or something with a comment saying it will dedup etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added a doc comment, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel strongly about it but I feel like reading the code you would not expect new to do the sort + dedup etc. The doc helps though I'll leave the rest up to you.

@evaporei evaporei force-pushed the eva/dedup-triggers branch 2 times, most recently from 64d615a to c8f629a Compare October 14, 2022 19:44
@evaporei evaporei marked this pull request as ready for review October 14, 2022 19:55

- This release includes a **determinism fix** that should affect very few subgraphs on the network (currently only two). There was an issue that if a subgraph manifest had one data source with no contract address, listening to the same events or calls of another data source that has a specified address, the handlers for those would be called twice. With the fix, this will happen no more, the handler will be called just once like it should.
- The two affected deployments are: `Qmccst5mbV5a6vT6VvJMLPKMAA1VRgT6NGbxkLL8eDRsE7` and `Qmd9nZKCH8UZU1pBzk7G8ECJr3jX3a2vAf3vowuTwFvrQg`;
- Here's an example [manifest](https://ipfs.io/ipfs/Qmd9nZKCH8UZU1pBzk7G8ECJr3jX3a2vAf3vowuTwFvrQg), taking a look at the data sources of name `ERC721` and `CryptoKitties`, both listen to the `Transfer(...)` event. Considering a block where there's only one occurence of this event, `graph-node` would duplicate it and call `handleTransfer` twice. Now this is fixed and it will be called only once per event/call that happened on chain.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is mentioning the network impact it's important to note any impact to indexers and any actions they should take.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome, thanks for the feedback I'll address it 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just pushed what they should do, what do you think? @leoyvens

Copy link
Collaborator

Choose a reason for hiding this comment

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

lgtm

If multiple data sources fetch the same event/call/etc,
they could exist twice inside the trigger_data.

This commit removes this duplication by running a .dedup()
after the sort.
@evaporei evaporei merged commit 57975f6 into master Nov 8, 2022
@evaporei evaporei deleted the eva/dedup-triggers branch November 8, 2022 01:53
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.

None yet

3 participants