Skip to content

Optimize RPC API Calls to Reduce Glif Bill #120

@NikolasHaimerl

Description

@NikolasHaimerl

Description

We need to optimize the smart contract state query to make the RPC API requests cache-able by Glif. Currently, our implementation is causing excessive RPC calls which is significantly increasing our Glif bill.

Background

This issue was identified in PR #117 where we're adding ethers.js as a dependency to address miners not having their scores recorded. While implementing this solution, we discovered that our current approach to state queries is not optimal for cacheability.

Proposed Solution

  1. Use the existing rpc helper in lib/miner-info.js to make RPC API calls directly
  2. Rework smart contract state queries to ask for state as of a given tipset
  3. Implement a lightweight solution to parse binary responses to JavaScript objects

Implementation Notes

  • We already use the rpc helper for MinerInfo state queries
  • This approach may be easier than using Ethers.js or viem for this specific use case
  • The optimization should be implemented soon after the initial version deployment (within days)

Related PR

Metadata

Metadata

Labels

No labels
No labels

Projects

Status

📥 candidate

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions