Conseil icon indicating copy to clipboard operation
Conseil copied to clipboard

Remove usage of offsets to fetch blocks data in favour of levels

Open ivanopagano opened this issue 4 years ago • 0 comments

Tezos RPC calls allows to fetch data referring to a block-related resource (including the block itself) both by

  1. using the block hash (and optional offset from there to get previous/successive blocks)
  2. using the block level

Conseil currently uses the offset approach (1.) for all request, which can become considerably more complicated and error prone. This is especially true when the requested levels are known before-hand, instead of being dynamically derived from the chain head block.

We want to switch to using the level reference in all appropriate places, and leaving the additional option to ask for block hash + offset, too, in all calls where that might be considered a useful feature.

A quick survey of the codebase actually identifies only 2 main spots where the impact will be major

  • TezosNodeFetchers will need to convert their input to accept levels as values for anything block related, possibly keeping both alternative input as required
  • TezosNodeOperator is where most of the computations regarding block reference is done and the fetchers are actually called, so all computations based on offsets will probably need be changed there to simplify reasoning

The main entrypoints of the indexer is already based on levels, which will make things smoother.

ivanopagano avatar Sep 09 '20 16:09 ivanopagano