Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements caching for ENS resolved addresses to prevent repeated DNS lookups to the Ethereum node when checking package versions.
- Adds an optional
contractAddressparameter togetVersionAndIpfsHashmethod to bypass ENS resolution - Introduces a module-level cache map to store resolved contract addresses by package name
- Updates the auto-update flow to cache and reuse contract addresses after initial ENS resolution
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/toolkit/src/repository/apmRepository.ts | Adds optional contractAddress parameter and logic to skip ENS resolution when address is provided |
| packages/daemons/src/autoUpdates/updateMyPackages.ts | Implements contract address caching using a module-level map and updates package checking flow |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import { flagCompletedUpdate } from "./flagCompletedUpdate.js"; | ||
| import { isDnpUpdateEnabled } from "./isDnpUpdateEnabled.js"; | ||
|
|
||
| const contractAddressMap: Record<string, string> = {}; |
There was a problem hiding this comment.
The module-level cache lacks persistence and will be cleared on process restart. Consider using a more robust caching mechanism or adding cache invalidation logic to handle cases where contract addresses might change.
| if (typeof repoContract.target === "string") { | ||
| logs.info(`Caching contract address for ${dnpName}: ${repoContract.target}`); | ||
| contractAddress = repoContract.target; | ||
| contractAddressMap[dnpName] = contractAddress; | ||
| } |
There was a problem hiding this comment.
The cache is only populated when repoContract.target is a string, but the cached address is used unconditionally. If target is not a string, contractAddress remains undefined but the code continues to use it, potentially causing issues.
|
Dappnode bot has built and pinned the built packages to an IPFS node, for commit: defc266 This is a development version and should only be installed for testing purposes.
Hash: (by dappnodebot/build-action) |
Cache ENS resolved addresses to avoid future useless requests to ETH node