effigy.im
effigy.im copied to clipboard
Implement caching for ENS resolutions and Ethereum address lookups
This pull request was created by Sweep to resolve the following request by @harperreed:
- [ ] Optimize ENS and Ethereum interactions
- [ ] Implement local caching for ENS resolutions and Ethereum address lookups
- [ ] Set up a Firebase Realtime Database or Firestore to store frequently requested data
feel free to check out and update the todo.md as needed
Continue chatting at https://sweep-chat-demo.vercel.app/c/71cd5d48-0419-4a5e-a7da-eb1991b35f98.
Purpose
This pull request aims to optimize the performance of the effigy.im application by implementing caching for ENS resolutions and Ethereum address lookups.
Description
The changes in this pull request include:
- Updating the
firebase.json
file to configure the Firebase Realtime Database rules, allowing read access to theaddressCache
node and write access only for authenticated users. - Adding a new
database.js
file in thefunctions
directory, which contains two functions:-
getCachedAddress(addressOrENS)
: Retrieves a cached Ethereum address from the Realtime Database, if available. -
setCachedAddress(addressOrENS, resolvedAddress)
: Stores a resolved Ethereum address in the Realtime Database cache.
-
- Updating the
index.js
file in thefunctions
directory to check the cache before attempting to resolve an Ethereum address or ENS name. If a cached address is found, it is returned immediately. If not, the address is resolved and the result is cached for future use.
Summary
The key changes in this pull request are:
-
firebase.json
: Updated the Realtime Database rules to allow read access to theaddressCache
node. -
functions/database.js
: Added new functions to retrieve and store cached Ethereum addresses. -
functions/index.js
: Implemented caching logic for Ethereum address and ENS name resolution.
Summary by CodeRabbit
-
New Features
- Introduced a caching mechanism for address resolution, improving performance and reducing redundant queries.
- Enhanced database security with stricter access controls, allowing public read access to certain data while restricting write access to authenticated users.
-
Bug Fixes
- Resolved issues related to address resolution efficiency by implementing caching for frequently queried addresses.
-
Documentation
- Updated task list to reflect completed optimizations and introduced new tasks focused on monitoring caching performance.