TrueBlocks / trueblocks-core

The main repository for the TrueBlocks system
https://trueblocks.io
GNU General Public License v3.0
1.05k stars 197 forks source link

Less confusing tracing detection #3582

Closed dszlachta closed 3 months ago

dszlachta commented 5 months ago

Currently our algorithm for detecting if the node is tracing is as follows:

But it's possible that a user's node doesn't have block X, because it's partial archive node (like it happened here: https://discord.com/channels/570963863428661248/811272718224719892/1230107993144823808)

I suggest we check if the error is related to tracing. If it's "missing block" then we exit with a proper message.

tjayrush commented 4 months ago

The code in question is here: https://github.com/TrueBlocks/trueblocks-core/blob/develop/src/apps/chifra/pkg/rpc/is_node.go.

There's actually two functions here:

  1. IsNodeArchive
  2. IsNodeTracing

IsNodeTracing has the idea of FirstBlock, but that value is hard coded. Perhaps we can add a per-chain config item for FirstBlock.

dszlachta commented 4 months ago

I still think we should differentiate between block not found and no tracing errors. Otherwise users can get confusing message (they can miss the part about setting the first block in the documentation)

tjayrush commented 4 months ago

I agree. There's two different things. IsNodeArchive and IsNodeTracing. I think they may be slightly combined in the existing code. It would be more clear to end users if we separated errors.

tjayrush commented 3 months ago

I changed three things:

  1. We now return not only a boolean indicating if there was an error, but also the actual error so the user gets whatever error is returned by the node, and
  2. The user may now export an environment variable (TB_<chain>_FIRSTTRACE) to instruct the code which block to test. (Defaults to 1 if not specified.)
  3. Added documentation in FAQ.