onflow / flow-go

A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them.
GNU Affero General Public License v3.0
531 stars 170 forks source link

[Access] Improve error messages when querying old blocks #4904

Open peterargue opened 8 months ago

peterargue commented 8 months ago

Problem Definition

Access nodes only have data from the current spork, and return errors when queried for data they don't have in their local dbs.

Currently, queries for heights before the root height results in generic NotFound errors. Since the start height never changes, nodes could check and return a more user friendly error in this case.

Proposed Solution

When querying based on block height (e.g. ExecuteScriptByHeight, GetBlockByHeight, GetBlockHeaderByHeight, GetEventsForHeightRange, GetAccountAtBlockHeight), if the block is not found, check the the height. It should be in one of these 3 categories

  1. Less than the spork root block height. The caller should try using a historic node.
  2. Less than the node's root block height (if the node was started after a spork). The caller should try using a different Access node.
  3. Greater than the node's finalized height. We don't need to handle this case, just adding it for completeness.

For 1 and 2, include in the error message the context so the caller knows how to respond.

github-actions[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.