-
Notifications
You must be signed in to change notification settings - Fork 29
Description
The following method does a MaxAsync on the BlockProgress table but the LastBlockProcessed column is set to NVARCHAR in the SQL scripts supplied, as a result, the query will return a value to the nearest 9, 99, 999 etc and not the actual last block processed, this can cause the processor to re-process a large number of blocks when restarted.
Nethereum.BlockchainStorage/src/Nethereum.BlockchainStore.EF/Repositories/BlockProgressRepository.cs
Line 18 in 60e62b7
| public async Task<BigInteger?> GetLastBlockNumberProcessedAsync() |
public async Task<BigInteger?> GetLastBlockNumberProcessedAsync() { using (var context = _contextFactory.CreateContext()) { var max = await context.BlockProgress.MaxAsync(b => b.LastBlockProcessed).ConfigureAwait(false); return string.IsNullOrEmpty(max) ? (BigInteger?)null : BigInteger.Parse(max); } }
Steps to recreate
-
Add 19999 blocks in the `BlockProgress` table -
Now run `SELECT Max([LastBlockProcessed]) FROM [BlockProgress]` -
Result returned 9999 as LastBlockProcessed resulting in 10k blocks needing to be reprocessed -
Expected query to return 19999 as LastBlockProcessed