o1-labs / Archive-Node-API

This is a GraphQL server that is built with the intention of exposing information from Mina's Archive Node
17 stars 4 forks source link

Fix duplicated events/actions from queries #63

Closed MartinMinkov closed 1 year ago

MartinMinkov commented 1 year ago

Description

During testing, it was found that there would sometimes be duplicate events/actions being returned from the Archive Node API. This PR aims to fix the issue by addressing existing bugs.

  1. The blocks SQL CTE was incorrect and was reporting duplicate blocks. This was solved by adding the DISTINCT keyword, which forces the SQL query only to return distinct rows for each block height.
  2. Fix the filterDuplicateBlocks method to correctly skip over adding a block if it's already been seen. In some cases, blocks were being incorrectly added if they were already seen and marked to be filtered out. Add a continue so that we do not add duplicate block data, which results in duplicate events.