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

Add cache to GetContractCurrency #107

Closed xiangliu-cb closed 1 year ago

xiangliu-cb commented 1 year ago

Fixes # .

Motivation

/block rosetta api is slow where there are spam contract interactions exists in a block. It happens in base and bsc. It will cause indexer timeout and paused network processing in the end.

Solution

The root cause is when populate transactions for a block we will need to call GetContractCurrency for each transaction and it takes time. For spam contract above ^ they should all be same so we could cache it instead.

Test in local as benchmark

Before: /block request takes 8 minutes for this bsc-testnet block

Screenshot 2023-10-24 at 5 35 30 PM

After: /block request takes 2 seconds for this bsc-testnet block

Screenshot 2023-10-24 at 5 39 26 PM

Open questions