routing-api
routing-api copied to clipboard
fix: filter out expired routes by ttl in the RoutesDB read path
In prod, we noticed that the RoutesDB can return cached routes, that we can no longer query from RoutesDB:
From https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html, "You can still update the expired items that are pending deletion, including changing or removing their TTL attributes". This can explain why the expired routes can still get returned from RoutesDB and used in router for quoting.
Testing wise, I used e2e tests on my local https://app.warp.dev/block/zcIboiQ5gWWjNGat5cWsFE. The idea here is that, meanwhile the tests are running, I expect the RoutesDB to get queried live one by one, so RoutesDbQuery is the highest. Then I expect RoutesDbPreFilterEntriesFound and RoutesDbEntriesFound to be always equal, and the reason is because we just created the routes in the local RoutesDB, there's no way they can get filtered out by unmatched protocol version, or TTL expiry:
