trueblocks-core icon indicating copy to clipboard operation
trueblocks-core copied to clipboard

Less confusing tracing detection

Open dszlachta opened this issue 1 year ago • 3 comments

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

  • Get trace for block number X
  • If error node is not tracing (defined in https://github.com/TrueBlocks/trueblocks-core/blob/master/src/apps/chifra/pkg/rpc/is_node.go#L41)

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.

dszlachta avatar Apr 17 '24 10:04 dszlachta

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.

tjayrush avatar Apr 20 '24 11:04 tjayrush

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)

dszlachta avatar Apr 23 '24 07:04 dszlachta

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 avatar Apr 23 '24 11:04 tjayrush

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.

tjayrush avatar Jun 02 '24 21:06 tjayrush