Skip to content

Commit 4bc8d2d

Browse files
authored
Merge pull request #345 from dappnode/v0.2.27
v0.2.27 Release
2 parents 128675c + 2ed5b85 commit 4bc8d2d

File tree

7 files changed

+52
-14
lines changed

7 files changed

+52
-14
lines changed

build/src/src/calls/fetchCoreUpdateData.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export async function getCoreUpdateData(
4949
*/
5050
const coreDnp = dnpList.find(_dnp => _dnp.name === coreName);
5151
const coreRelease = coreDnpsToBeInstalled[coreName];
52+
if (!coreRelease)
53+
throw Error(
54+
`No coreRelease found: ${Object.keys(coreDnpsToBeInstalled).join(", ")}`
55+
);
5256
if (!coreDnp) delete coreDnpsToBeInstalled[coreName];
5357

5458
const packages = Object.entries(coreDnpsToBeInstalled).map(

build/src/src/db/ethClient.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
EthClientTarget,
55
UserSettings,
66
EthClientFallback,
7-
EthClientStatus
7+
EthClientStatus,
8+
EthClientTargetPackage
89
} from "../types";
910
import { joinWithDot, stripDots } from "./dbUtils";
1011
import { EthClientInstallStatus } from "../modules/ethClient/types";
@@ -18,6 +19,8 @@ const ETH_CLIENT_USER_SETTINGS = "eth-client-user-settings";
1819
const ETH_CLIENT_INSTALL_STATUS = "eth-client-install-status";
1920
const ETH_CLIENT_STATUS = "eth-client-status";
2021
const ETH_PROVIDER_URL = "eth-provider-url";
22+
// Cached temp status
23+
const ETH_CLIENT_MIGRATION_TEMP_SETTINGS = "eth-client-migration-temp-status";
2124

2225
// Re-export to consider the first value (when it's not set)
2326
// but do not allow to set null again. Using to express intentionality
@@ -96,3 +99,13 @@ function interceptOnSet<F extends Function, T extends { set: F }>(
9699
}
97100
};
98101
}
102+
103+
/**
104+
* Temporal cache settings that must survive a reset
105+
* Store settings in the cache. It is possible that the migration is stopped
106+
* because the DAPPMANAGER resets and then the eth client will not be installed
107+
*/
108+
export const ethClientMigrationTempSettings = dbCache.staticKey<{
109+
target: EthClientTargetPackage;
110+
EXTRA_OPTS: string;
111+
} | null>(ETH_CLIENT_MIGRATION_TEMP_SETTINGS, null);

build/src/src/modules/docker/listContainers.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ export async function listContainerNoThrow(
106106
byName: string
107107
): Promise<PackageContainer | null> {
108108
const containers = await dockerList({ filters: { name: [byName] } });
109-
return containers[0] ? parseContainerInfo(containers[0]) : null;
109+
if (!containers[0]) return null;
110+
const container = parseContainerInfo(containers[0]);
111+
// When querying "geth.dnp.dappnode.eth", if user has "goerli-geth.dnp.dappnode.eth"
112+
// The latter can be returned as the original container.
113+
if (container.name !== byName) return null;
114+
else return container;
110115
}
111116

112117
export async function listContainer(byName: string): Promise<PackageContainer> {
@@ -140,7 +145,7 @@ function parseContainerInfo(container: ContainerInfo): PackageContainer {
140145
const isDnp = packageName.includes(CONTAINER_NAME_PREFIX);
141146
const isCoreByName = packageName.includes(CONTAINER_CORE_NAME_PREFIX);
142147

143-
let name;
148+
let name = "";
144149
if (isDnp) name = packageName.split(CONTAINER_NAME_PREFIX)[1] || "";
145150
else if (isCoreByName)
146151
name = packageName.split(CONTAINER_CORE_NAME_PREFIX)[1] || "";

build/src/src/modules/ethClient/changeEthMultiClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ export async function changeEthMultiClient(
1818
userSettings?: UserSettings
1919
): Promise<void> {
2020
const prevTarget = db.ethClientTarget.get();
21-
if (prevTarget === nextTarget) throw Error("Same target");
2221

2322
// Set user settings of next target if any
2423
if (userSettings) db.ethClientUserSettings.set(nextTarget, userSettings);
2524

2625
// If the previous client is a client package, uninstall it
27-
if (prevTarget && prevTarget !== "remote") {
26+
if (prevTarget !== nextTarget && prevTarget && prevTarget !== "remote") {
2827
try {
2928
const clientData = ethClientData[prevTarget];
3029
if (clientData) {
@@ -40,7 +39,7 @@ export async function changeEthMultiClient(
4039

4140
// Setting the status to selected will trigger an install
4241
db.ethClientTarget.set(nextTarget);
43-
if (nextTarget !== "remote") {
42+
if (prevTarget !== nextTarget && nextTarget !== "remote") {
4443
db.ethClientInstallStatus.set(nextTarget, { status: "TO_INSTALL" });
4544
eventBus.runEthClientInstaller.emit();
4645
}

build/src/src/modules/ethClient/migrateEthchain.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "fs";
2+
import * as db from "../../db";
23
import { changeEthMultiClient } from "./changeEthMultiClient";
34
import { listContainerNoThrow } from "../../modules/docker/listContainers";
45
import { dockerVolumesList, dockerDf } from "../../modules/docker/dockerApi";
@@ -8,6 +9,7 @@ import { getUserSettingsSafe } from "../../utils/dockerComposeFile";
89
import * as getPath from "../../utils/getPath";
910
import shell from "../../utils/shell";
1011
import Logs from "../../logs";
12+
import { EthClientTargetPackage } from "../../types";
1113
const logs = Logs(module);
1214

1315
const ethchainDnpName = "ethchain.dnp.dappnode.eth";
@@ -46,6 +48,14 @@ export async function migrateEthchain(): Promise<void> {
4648
...(userSettings.environment || {})
4749
};
4850
const isNextOpenEthereum = /parity/i.test(envs.DEFAULT_CLIENT || "");
51+
let target: EthClientTargetPackage = isNextOpenEthereum
52+
? "openethereum"
53+
: "geth";
54+
let EXTRA_OPTS =
55+
(isNextOpenEthereum ? envs.EXTRA_OPTS : envs.EXTRA_OPTS_GETH) || "";
56+
// Store settings in the cache. It is possible that the migration is stopped
57+
// because the DAPPMANAGER resets and then the eth client will not be installed
58+
db.ethClientMigrationTempSettings.set({ target, EXTRA_OPTS });
4959

5060
const volumesToMigrate = [
5161
{
@@ -142,16 +152,23 @@ export async function migrateEthchain(): Promise<void> {
142152
}
143153

144154
// Install new package. fullnode.dappnode is assigned after install
145-
if (ethchain) {
146-
const target = isNextOpenEthereum ? "openethereum" : "geth";
147-
const EXTRA_OPTS = isNextOpenEthereum
148-
? envs.EXTRA_OPTS
149-
: envs.EXTRA_OPTS_GETH;
150-
logs.info(`Installing eth multi-client ${target}: ${JSON.stringify(envs)}`);
155+
const migrationTempSettings = db.ethClientMigrationTempSettings.get();
156+
if (ethchain || migrationTempSettings) {
157+
logs.info(
158+
`Installing eth multi-client ${target}: with EXTRA_OPTS ${EXTRA_OPTS}`
159+
);
160+
161+
if (migrationTempSettings) {
162+
target = migrationTempSettings.target || target;
163+
EXTRA_OPTS = migrationTempSettings.EXTRA_OPTS || EXTRA_OPTS;
164+
}
151165

152166
await changeEthMultiClient(target, false, {
153167
portMappings: userSettings.portMappings,
154168
environment: EXTRA_OPTS ? { EXTRA_OPTS } : undefined
155169
});
170+
171+
// Once the client has been successfully changed, delete temp migration settings
172+
db.ethClientMigrationTempSettings.set(null);
156173
}
157174
}

dappnode_package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dappmanager.dnp.dappnode.eth",
3-
"version": "0.2.26",
3+
"version": "0.2.27",
44
"description": "Dappnode package responsible for providing the DappNode Package Manager",
55
"type": "dncore",
66
"author": "DAppNode Association <admin@dappnode.io> (https://github.com/dappnode)",

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
build:
1313
context: .
1414
dockerfile: ./build/Dockerfile
15-
image: 'dappmanager.dnp.dappnode.eth:0.2.26'
15+
image: 'dappmanager.dnp.dappnode.eth:0.2.27'
1616
container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth
1717
restart: always
1818
volumes:

0 commit comments

Comments
 (0)