ethereum / trin

An Ethereum portal client: a json-rpc server with nearly instant sync, and low CPU & storage usage
365 stars 113 forks source link

portalnet/overlay: `FindContent` query doesn't check for the content in database before making network requests #1329

Open ogenev opened 3 months ago

ogenev commented 3 months ago

The core FindContent query in OvelrayService does not check local database for the content before making network requests.

This cause an issue when we send commands to the OverlayService from external services.

For example, when we request a content in the light-client module, the OverlayService ignores all content in the database and relies solely on network requests.

On the other side, when we do a RecursiveFindContent JSON-RPC call, we check for the content in the database but this is implemented only on the JSON-RPC level.

To allow external modules to communicate with OverlayService in a way to get the available content via either database or network request, it seems that we have two options:

Option 1: Check for content availability in database before sending network request on OverlayService level and remove the locality check from the JSON-RPC module.

Option 2: Implement a new OverlayService command that will explicitly check only for content availability in the database. External services then will have to send two commands to OverlayService - one to check for the content in the database and one to get the content from the network.