To improve /block latency. A major bottleneck is that contractCurrencyMap is created fresh for each transaction, so it only caches within a single transaction's logs. That's why we see repeated GetContractCurrency calls for the same contracts across different transactions.
Solution
Add an LRU cache that stores contract currency details across blocks. Also, don't go to the node for allow listed tokens to get symbol and decimals (if env var USE_TOKEN_WHITE_LIST_METADATA="true"), as they can be retrieved from the config.
Fixes
Improve caching of contract currency details.
Motivation
To improve /block latency. A major bottleneck is that contractCurrencyMap is created fresh for each transaction, so it only caches within a single transaction's logs. That's why we see repeated GetContractCurrency calls for the same contracts across different transactions.
Solution
Add an LRU cache that stores contract currency details across blocks. Also, don't go to the node for allow listed tokens to get symbol and decimals (if env var USE_TOKEN_WHITE_LIST_METADATA="true"), as they can be retrieved from the config.