Skip to content

Cache ENS resolved addresses#2242

Merged
pablomendezroyo merged 2 commits intodevelopfrom
pablomendezroyo-patch-2
Sep 8, 2025
Merged

Cache ENS resolved addresses#2242
pablomendezroyo merged 2 commits intodevelopfrom
pablomendezroyo-patch-2

Conversation

@pablomendezroyo
Copy link
Copy Markdown
Contributor

Cache ENS resolved addresses to avoid future useless requests to ETH node

@pablomendezroyo pablomendezroyo requested a review from a team as a code owner September 5, 2025 14:49
@github-actions github-actions bot temporarily deployed to commit September 8, 2025 07:25 Inactive
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 8, 2025

@Marketen Marketen requested a review from Copilot September 8, 2025 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 contractAddress parameter to getVersionAndIpfsHash method 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> = {};
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +44
if (typeof repoContract.target === "string") {
logs.info(`Caching contract address for ${dnpName}: ${repoContract.target}`);
contractAddress = repoContract.target;
contractAddressMap[dnpName] = contractAddress;
}
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 8, 2025

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.

  1. Package dappmanager.dnp.dappnode.eth

Install link

Hash: /ipfs/Qmf7dgTgkunQSBzwGRQ8QhxQTbx4nf7qESPgbFKPVy7fLH

(by dappnodebot/build-action)

@pablomendezroyo pablomendezroyo merged commit d073daf into develop Sep 8, 2025
7 checks passed
@pablomendezroyo pablomendezroyo deleted the pablomendezroyo-patch-2 branch September 8, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants