coinbase / mesh-geth-sdk

go-ethereum based sdk for Mesh API
https://docs.cdp.coinbase.com/mesh/docs/getting-started/
Apache License 2.0
28 stars 29 forks source link

Improve caching of contract currency details #136

Closed marklandgrebe-cb closed 4 weeks ago

marklandgrebe-cb commented 1 month ago

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.

cb-heimdall commented 1 month ago

✅ Heimdall Review Status

Requirement Status More Info
Reviews 3/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1