CRITICAL] Severe Time Gaps in Raw orderfilled Parquets Causing Systemic Data Loss in Derived Datasets

#8
by wilsonwangwang - opened

Hi team,

Thank you for providing and maintaining this incredibly helpful dataset.

While validating user-level data and complement routing mechanics (as discussed in Issue #7) against the raw Goldsky subgraph, we uncovered a critical data loss issue.

The root cause of missing trades in the derived datasets (trades.parquet, users.parquet, quant.parquet) is not just the aggregate fill parsing logic. The underlying raw data (orderfilled_part1 to part4) itself contains massive time gaps (blackouts) where scraping apparently stalled or failed.

Evidence 1: Missing Specific Transactions
Take TX 0xfed9af49304b51599335c3ed1953ebc92da081c0ca6375d17891e2b0f9f4a9a2 (Timestamp: 1773689163 / 2026-03-16 19:26:03 UTC) as an example.

Querying the Goldsky API directly returns 31 OrderFilled events for this transaction (including a ~$21k USDC aggregate fill).
However, querying orderfilled_part4.parquet for this hash or timestamp returns 0 rows.
Evidence 2: Macro Time Gaps Across Parquets
Running a simple DuckDB window function to detect gaps larger than 10 minutes (next_ts - current_ts > 600) reveals hundreds of severe blackouts across the raw files:

In orderfilled_part4: On 2026-03-16 alone, there are two massive blackouts: ~33 mins (19:06 to 19:39 UTC) and ~30 mins (19:42 to 20:12 UTC).
In orderfilled_part2: There is a 60-hour gap (2025-12-04 to 2025-12-06), along with frequent 9 to 13-hour gaps in Feb 2026.
In orderfilled_part1: Hundreds of gaps, some lasting for days.
(You can easily reproduce this by running LEAD(timestamp) OVER (ORDER BY timestamp) on the raw parquets).

Impact
Because the foundational orderfilled data is incomplete, all downstream datasets (trades, users, quant) are systematically missing crucial market activities. During these blackout periods, massive whale sweeps and retail trades are completely wiped out, which severely distorts volume, PnL calculations, and quantitative backtesting results.

Request for Action
Could you please verify these time gaps on your end? It appears that a re-scrape or a targeted patching of these missing windows from Goldsky is urgently needed to restore the integrity of the dataset.

Looking forward to your prompt verification and a potential fix. Thank you for your hard work!

thank you very much for your contribution. I'm wondering whether your list of gaps is complete so that I can know whether my project is destroyed :(
(my project investigates data in 2024. it looks like safe without involving the gaps you provided.)

thank you very much for your contribution. I'm wondering whether your list of gaps is complete so that I can know whether my project is destroyed :(
(my project investigates data in 2024. it looks like safe without involving the gaps you provided.)

Hi @Eliven ,

Unfortunately, I have to deliver some bad news: your 2024 data is absolutely NOT safe.

The gaps I provided in the initial issue description were just a tiny preview (a small sample of the largest gaps). The data loss is a systemic issue spanning the entire dataset from 2022 to 2026.

I just ran a deep scan using DuckDB specifically targeting the year 2024 (Polygon blocks ~51,796,362 to ~66,185,466), and here are the exact statistics:

Number of separate gaps in 2024: 31,270
Total missing blocks in 2024: 3,062,481
Missing ratio for 2024: ~21.28% of the entire year's block history is completely missing.
Why did this happen? As mentioned in the issue, the official crawler in cli/main.py fetches data in batches of 100 blocks. If the public RPC node rate-limits the request or times out, the script catches the error, logs it, and executes a continue statement—permanently skipping those 100 blocks instead of retrying. Because 2024 had high network activity, the crawler failed and skipped blocks over 31,000 times.

How you can fix your 2024 data (Without starting from scratch): You don't need to re-download everything. You can patch the official code and fetch only the missing 2024 blocks:

  1. Find all your gaps: You can use DuckDB to scan your local parquet files and generate a complete list of missing block ranges. Here is the SQL query I used to find all the gaps:

WITH ordered_data AS (
SELECT block_number, LEAD(block_number) OVER (ORDER BY block_number) as next_block
FROM read_parquet('orderfilled_part*.parquet')
GROUP BY block_number
)
SELECT block_number + 1 AS start_block, next_block - 1 AS end_block
FROM ordered_data
WHERE next_block - block_number > 50
ORDER BY start_block;
(Export the results to a failed_blocks.txt file)

  1. Patch the crawler (CRITICAL): Before you try to fetch the missing data, you MUST modify polymarket/fetchers/rpc.py to use an Archive Node (like https://polygon.drpc.org instead of the default one) and add a time.sleep() + retry loop inside the get_logs function. Otherwise, the official script will just fail and skip blocks again.

  2. Recover: Use the official polymarket/tools/refetch_failed_blocks.py script, feed it the failed_blocks.txt generated in step 1, and it will download the missing 21% of your 2024 data. After that, use merge_orderfilled.py to combine them.

Hope this helps save your project! Let me know if you need the exact Python recovery scripts, I've already rewritten them to be multi-threaded and robust against RPC timeouts.

This comment has been hidden (marked as Resolved)

Thank you very much for your kind help! It sounds like just the pipeline is broken, where the original data from subgraph is safe. Actually, I didn't collect data from the orderfilled.parquet files here directly. Instead, I collect data from subgraph (https://gateway.thegraph.com/api/subgraphs/id/81Dm16JjuFSrqz813HysXoUPvzTwE7fsfPk2RTf66nyC). so I guess I'm safe, temporarily? Do you think so?
Thank you again!

thank you very much for your contribution. I'm wondering whether your list of gaps is complete so that I can know whether my project is destroyed :(
(my project investigates data in 2024. it looks like safe without involving the gaps you provided.)

Hi @Eliven ,

Unfortunately, I have to deliver some bad news: your 2024 data is absolutely NOT safe.

The gaps I provided in the initial issue description were just a tiny preview (a small sample of the largest gaps). The data loss is a systemic issue spanning the entire dataset from 2022 to 2026.

I just ran a deep scan using DuckDB specifically targeting the year 2024 (Polygon blocks ~51,796,362 to ~66,185,466), and here are the exact statistics:

Number of separate gaps in 2024: 31,270
Total missing blocks in 2024: 3,062,481
Missing ratio for 2024: ~21.28% of the entire year's block history is completely missing.
Why did this happen? As mentioned in the issue, the official crawler in cli/main.py fetches data in batches of 100 blocks. If the public RPC node rate-limits the request or times out, the script catches the error, logs it, and executes a continue statement—permanently skipping those 100 blocks instead of retrying. Because 2024 had high network activity, the crawler failed and skipped blocks over 31,000 times.

How you can fix your 2024 data (Without starting from scratch): You don't need to re-download everything. You can patch the official code and fetch only the missing 2024 blocks:

  1. Find all your gaps: You can use DuckDB to scan your local parquet files and generate a complete list of missing block ranges. Here is the SQL query I used to find all the gaps:

WITH ordered_data AS (
SELECT block_number, LEAD(block_number) OVER (ORDER BY block_number) as next_block
FROM read_parquet('orderfilled_part*.parquet')
GROUP BY block_number
)
SELECT block_number + 1 AS start_block, next_block - 1 AS end_block
FROM ordered_data
WHERE next_block - block_number > 50
ORDER BY start_block;
(Export the results to a failed_blocks.txt file)

  1. Patch the crawler (CRITICAL): Before you try to fetch the missing data, you MUST modify polymarket/fetchers/rpc.py to use an Archive Node (like https://polygon.drpc.org instead of the default one) and add a time.sleep() + retry loop inside the get_logs function. Otherwise, the official script will just fail and skip blocks again.

  2. Recover: Use the official polymarket/tools/refetch_failed_blocks.py script, feed it the failed_blocks.txt generated in step 1, and it will download the missing 21% of your 2024 data. After that, use merge_orderfilled.py to combine them.

Hope this helps save your project! Let me know if you need the exact Python recovery scripts, I've already rewritten them to be multi-threaded and robust against RPC timeouts.

Thank you very much for your kind help! It sounds like just the pipeline is broken, where the original data from subgraph is safe. Actually, I didn't collect data from the orderfilled.parquet files here directly. Instead, I collect data from subgraph (https://thegraph.com/explorer/subgraphs/81Dm16JjuFSrqz813HysXoUPvzTwE7fsfPk2RTf66nyC?view=Query&chain=arbitrum-one). so I guess I'm safe, temporarily? Do you think so?
Thank you again!

Sign up or log in to comment