Some apps that use blockchain-core without intending to follow the chain (e.g. the Helium miner) will receive a crash notice in blockchain_worker every 90 seconds after it attempts to start up. This is likely due to the code attempting to perform a delayed "cache pre-warm" on the local ledger, even if there is no local ledger being used.
Expected behavior
If an app has signaled to blockchain_worker that it is not a chain follower (application:get_env(blockchain, autoload) returns undefined or false), it should not attempt to pre-warm the ledger cache.
Logs
2022-12-13 17:50:21.327 1 [error] emulator@Undefined:Undefined:Undefined Error in process <0.1719.0> on node 'miner@127.0.0.1' with exit value:
{function_clause,[{blockchain,ledger,[undefined],[{file,"blockchain.erl"},{line,556}]},{blockchain_worker,'-init/1-fun-4-',0,[{file,"blockchain_worker.erl"},{line,437}]}]}
Likely source
The likely source of the issue is this section of the blockchain_worker startup, which spawns a function that eventually attempts to instantiate a ledger, regardless of whether the app is following the chain:
Summary
Some apps that use blockchain-core without intending to follow the chain (e.g. the Helium miner) will receive a crash notice in
blockchain_worker
every 90 seconds after it attempts to start up. This is likely due to the code attempting to perform a delayed "cache pre-warm" on the local ledger, even if there is no local ledger being used.Expected behavior
If an app has signaled to
blockchain_worker
that it is not a chain follower (application:get_env(blockchain, autoload)
returnsundefined
orfalse
), it should not attempt to pre-warm the ledger cache.Logs
Likely source
The likely source of the issue is this section of the
blockchain_worker
startup, which spawns a function that eventually attempts to instantiate a ledger, regardless of whether the app is following the chain:https://github.com/helium/blockchain-core/blob/f71f7efc391633913287f685408ae1e9f8709adf/src/blockchain_worker.erl#L435