diff --git a/packages/stakers/src/consensus.ts b/packages/stakers/src/consensus.ts index d4967041d..c278ff0e8 100644 --- a/packages/stakers/src/consensus.ts +++ b/packages/stakers/src/consensus.ts @@ -102,6 +102,7 @@ export class Consensus extends StakerComponent { await super.setNew({ newStakerDnpName: newConsensusDnpName, dockerNetworkName: params.DOCKER_STAKER_NETWORKS[network], + fullnodeAlias: `consensus.${network}.dncore.dappnode`, compatibleClients: Consensus.CompatibleConsensus[network], userSettings, prevClient: prevConsClientDnpName diff --git a/packages/stakers/src/execution.ts b/packages/stakers/src/execution.ts index e067f3c54..112af4c7a 100644 --- a/packages/stakers/src/execution.ts +++ b/packages/stakers/src/execution.ts @@ -97,6 +97,7 @@ export class Execution extends StakerComponent { await super.setNew({ newStakerDnpName: newExecutionDnpName, dockerNetworkName: params.DOCKER_STAKER_NETWORKS[network], + fullnodeAlias: `execution.${network}.dncore.dappnode`, compatibleClients: Execution.CompatibleExecutions[network], userSettings: await this.getUserSettings(network, newExecutionDnpName), prevClient: prevExecClientDnpName diff --git a/packages/stakers/src/mevBoost.ts b/packages/stakers/src/mevBoost.ts index 9d57c65c1..4ca675d1e 100644 --- a/packages/stakers/src/mevBoost.ts +++ b/packages/stakers/src/mevBoost.ts @@ -84,6 +84,7 @@ export class MevBoost extends StakerComponent { await super.setNew({ newStakerDnpName: newMevBoostDnpName, dockerNetworkName: params.DOCKER_STAKER_NETWORKS[network], + fullnodeAlias: `mev-boost.${network}.dncore.dappnode`, compatibleClients: compatibleMevBoost ? [compatibleMevBoost] : null, userSettings: newMevBoostDnpName ? this.getUserSettings(network, newRelays) : {}, prevClient: compatibleMevBoost ? compatibleMevBoost.dnpName : null diff --git a/packages/stakers/src/signer.ts b/packages/stakers/src/signer.ts index 3ea1cc453..b0be7608f 100644 --- a/packages/stakers/src/signer.ts +++ b/packages/stakers/src/signer.ts @@ -67,6 +67,7 @@ export class Signer extends StakerComponent { await super.setNew({ newStakerDnpName: newWeb3signerDnpName, dockerNetworkName: params.DOCKER_STAKER_NETWORKS[network], + fullnodeAlias: `signer.${network}.dncore.dappnode`, compatibleClients: [Signer.CompatibleSigners[network]], userSettings: this.getUserSettings(network), prevClient: Signer.CompatibleSigners[network].dnpName diff --git a/packages/stakers/src/stakerComponent.ts b/packages/stakers/src/stakerComponent.ts index f3be15d8b..24417647f 100644 --- a/packages/stakers/src/stakerComponent.ts +++ b/packages/stakers/src/stakerComponent.ts @@ -56,12 +56,14 @@ export class StakerComponent { protected async setNew({ newStakerDnpName, dockerNetworkName, + fullnodeAlias, compatibleClients, userSettings, prevClient }: { newStakerDnpName: string | null | undefined; dockerNetworkName: string; + fullnodeAlias: string; compatibleClients: | { dnpName: string; @@ -83,7 +85,8 @@ export class StakerComponent { if (currentPkg) { if (prevClient && compatibleClients) this.ensureCompatibilityRequirements(prevClient, compatibleClients, currentPkg.version); - if (prevClient !== newStakerDnpName) await this.unsetStakerPkgConfig(currentPkg, dockerNetworkName); + if (prevClient !== newStakerDnpName) + await this.unsetStakerPkgConfig({ pkg: currentPkg, dockerNetworkName, fullnodeAlias }); } if (!newStakerDnpName) return; @@ -178,8 +181,17 @@ export class StakerComponent { * - stops the staker pkg * - removes the staker network from the docker-compose file */ - private async unsetStakerPkgConfig(pkg: InstalledPackageData, dockerNetworkName: string): Promise { + private async unsetStakerPkgConfig({ + pkg, + dockerNetworkName, + fullnodeAlias + }: { + pkg: InstalledPackageData; + dockerNetworkName: string; + fullnodeAlias: string; + }): Promise { this.removeStakerNetworkFromCompose(pkg.dnpName, dockerNetworkName); + this.removeFullnodeAliasFromDncoreNetwork(pkg.dnpName, fullnodeAlias); // This recreates the package containers so that they include the recently added configuration // The flag --no-start is added so that the containers remain stopped after recreation @@ -190,6 +202,26 @@ export class StakerComponent { }); } + private removeFullnodeAliasFromDncoreNetwork(dnpName: string, fullnodeAlias: string): void { + const composeEditor = new ComposeFileEditor(dnpName, false); + const services = composeEditor.compose.services; + + for (const [, service] of Object.entries(services)) { + const serviceNetworks = service.networks; + + if (!serviceNetworks || Array.isArray(serviceNetworks)) continue; + + for (const [networkName, networkSettings] of Object.entries(serviceNetworks)) { + if (networkName === params.DOCKER_PRIVATE_NETWORK_NAME) { + const aliases = networkSettings.aliases; + if (aliases) networkSettings.aliases = aliases.filter((alias) => alias !== fullnodeAlias); + } + } + } + + composeEditor.write(); + } + private removeStakerNetworkFromCompose(dnpName: string, dockerNetworkName: string): void { const composeEditor = new ComposeFileEditor(dnpName, false); const services = composeEditor.compose.services;