Skip to content

Commit

Permalink
Remove logic related to beacon-validator service
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Aug 16, 2024
1 parent bafd376 commit e8f2ed5
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 204 deletions.
9 changes: 2 additions & 7 deletions packages/installer/src/ethClient/apiUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildNetworkAlias, getBeaconServiceName } from "@dappnode/utils";
import { buildNetworkAlias } from "@dappnode/utils";
import { listPackageNoThrow } from "@dappnode/dockerapi";

/**
Expand Down Expand Up @@ -43,14 +43,9 @@ export async function getEthConsClientApiUrl(dnpName: string): Promise<string> {
isMainOrMonoservice: false,
});
} else {
// Lighthouse, Teku and Prysm use 3500
// Nimbus uses 4500 because it is a monoservice and the validator API is using that port
if (dnpName.includes("nimbus")) {
port = 4500;
}
domain = buildNetworkAlias({
dnpName: dnpName,
serviceName: getBeaconServiceName(dnpName),
serviceName: "beacon-chain",
isMainOrMonoservice: false,
});
}
Expand Down
216 changes: 78 additions & 138 deletions packages/stakers/src/consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Network,
StakerItem,
UserSettings,
UserSettingsAllDnps,
} from "@dappnode/types";
import { StakerComponent } from "./stakerComponent.js";
import { DappnodeInstaller } from "@dappnode/installer";
Expand All @@ -26,12 +25,12 @@ export class Consensus extends StakerComponent {
set: (globEnvValue: string | null | undefined) => Promise<void>;
}
> = {
[Network.Mainnet]: db.consensusClientMainnet,
[Network.Gnosis]: db.consensusClientGnosis,
[Network.Prater]: db.consensusClientPrater,
[Network.Holesky]: db.consensusClientHolesky,
[Network.Lukso]: db.consensusClientLukso,
};
[Network.Mainnet]: db.consensusClientMainnet,
[Network.Gnosis]: db.consensusClientGnosis,
[Network.Prater]: db.consensusClientPrater,
[Network.Holesky]: db.consensusClientHolesky,
[Network.Lukso]: db.consensusClientLukso,
};
protected static readonly DefaultCheckpointSync: Record<Network, string> = {
[Network.Mainnet]: "https://checkpoint-sync.dappnode.io",
[Network.Prater]: "https://checkpoint-sync-prater.dappnode.io",
Expand All @@ -43,38 +42,38 @@ export class Consensus extends StakerComponent {
Network,
{ dnpName: string; minVersion: string }[]
> = {
[Network.Mainnet]: [
{ dnpName: ConsensusClientMainnet.Prysm, minVersion: "3.0.4" },
{ dnpName: ConsensusClientMainnet.Lighthouse, minVersion: "1.0.3" },
{ dnpName: ConsensusClientMainnet.Teku, minVersion: "2.0.4" },
{ dnpName: ConsensusClientMainnet.Nimbus, minVersion: "1.0.5" },
{ dnpName: ConsensusClientMainnet.Lodestar, minVersion: "0.1.0" },
],
[Network.Gnosis]: [
{ dnpName: ConsensusClientGnosis.Lighthouse, minVersion: "0.1.5" },
{ dnpName: ConsensusClientGnosis.Teku, minVersion: "0.1.5" },
{ dnpName: ConsensusClientGnosis.Lodestar, minVersion: "0.1.0" },
{ dnpName: ConsensusClientGnosis.Nimbus, minVersion: "0.1.0" },
],
[Network.Prater]: [
{ dnpName: ConsensusClientPrater.Prysm, minVersion: "1.0.15" },
{ dnpName: ConsensusClientPrater.Lighthouse, minVersion: "0.1.9" },
{ dnpName: ConsensusClientPrater.Teku, minVersion: "0.1.10" },
{ dnpName: ConsensusClientPrater.Nimbus, minVersion: "0.1.7" },
{ dnpName: ConsensusClientPrater.Lodestar, minVersion: "0.1.0" },
],
[Network.Holesky]: [
{ dnpName: ConsensusClientHolesky.Lighthouse, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Prysm, minVersion: "0.1.3" },
{ dnpName: ConsensusClientHolesky.Teku, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Nimbus, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Lodestar, minVersion: "0.1.3" },
],
[Network.Lukso]: [
{ dnpName: ConsensusClientLukso.Prysm, minVersion: "0.1.0" },
{ dnpName: ConsensusClientLukso.Teku, minVersion: "0.1.0" },
],
};
[Network.Mainnet]: [
{ dnpName: ConsensusClientMainnet.Prysm, minVersion: "3.0.4" },
{ dnpName: ConsensusClientMainnet.Lighthouse, minVersion: "1.0.3" },
{ dnpName: ConsensusClientMainnet.Teku, minVersion: "2.0.4" },
{ dnpName: ConsensusClientMainnet.Nimbus, minVersion: "1.0.5" },
{ dnpName: ConsensusClientMainnet.Lodestar, minVersion: "0.1.0" },
],
[Network.Gnosis]: [
{ dnpName: ConsensusClientGnosis.Lighthouse, minVersion: "0.1.5" },
{ dnpName: ConsensusClientGnosis.Teku, minVersion: "0.1.5" },
{ dnpName: ConsensusClientGnosis.Lodestar, minVersion: "0.1.0" },
{ dnpName: ConsensusClientGnosis.Nimbus, minVersion: "0.1.0" },
],
[Network.Prater]: [
{ dnpName: ConsensusClientPrater.Prysm, minVersion: "1.0.15" },
{ dnpName: ConsensusClientPrater.Lighthouse, minVersion: "0.1.9" },
{ dnpName: ConsensusClientPrater.Teku, minVersion: "0.1.10" },
{ dnpName: ConsensusClientPrater.Nimbus, minVersion: "0.1.7" },
{ dnpName: ConsensusClientPrater.Lodestar, minVersion: "0.1.0" },
],
[Network.Holesky]: [
{ dnpName: ConsensusClientHolesky.Lighthouse, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Prysm, minVersion: "0.1.3" },
{ dnpName: ConsensusClientHolesky.Teku, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Nimbus, minVersion: "0.1.2" },
{ dnpName: ConsensusClientHolesky.Lodestar, minVersion: "0.1.3" },
],
[Network.Lukso]: [
{ dnpName: ConsensusClientLukso.Prysm, minVersion: "0.1.0" },
{ dnpName: ConsensusClientLukso.Teku, minVersion: "0.1.0" },
],
};

constructor(dappnodeInstaller: DappnodeInstaller) {
super(dappnodeInstaller);
Expand Down Expand Up @@ -104,7 +103,6 @@ export class Consensus extends StakerComponent {
await this.persistSelectedIfInstalled({
dnpName: currentConsensusDnpName,
userSettings: this.getUserSettings(
currentConsensusDnpName,
isInstalled,
network
),
Expand All @@ -122,12 +120,11 @@ export class Consensus extends StakerComponent {
compatibleClients: Consensus.CompatibleConsensus[network],
userSettings: newConsensusDnpName
? this.getUserSettings(
newConsensusDnpName,
!Boolean(
await listPackageNoThrow({ dnpName: newConsensusDnpName })
),
network
)
!Boolean(
await listPackageNoThrow({ dnpName: newConsensusDnpName })
),
network
)
: {},
prevClient: prevConsClientDnpName,
});
Expand All @@ -137,45 +134,31 @@ export class Consensus extends StakerComponent {
}

private getUserSettings(
newConsensusDnpName: string,
shouldSetEnvironment: boolean,
network: Network
): UserSettings {
const validatorServiceName =
this.getValidatorServiceName(newConsensusDnpName);
const beaconServiceName = this.getBeaconServiceName(newConsensusDnpName);
const validatorServiceName = "validator";
const beaconServiceName = "beacon-chain";
const defaultDappnodeGraffiti = "validating_from_DAppNode";
const defaultFeeRecipient = "0x0000000000000000000000000000000000000000";
return {
environment: shouldSetEnvironment
? beaconServiceName === validatorServiceName
? {
[validatorServiceName]: {
// Fee recipient is set as global env, keep this for backwards compatibility
["FEE_RECIPIENT_ADDRESS"]: defaultFeeRecipient, // TODO: consider setting the MEV fee recipient as the default
// Graffiti is a mandatory value
["GRAFFITI"]: defaultDappnodeGraffiti,
// Checkpoint sync is an optional value
["CHECKPOINT_SYNC_URL"]:
Consensus.DefaultCheckpointSync[network],
},
}
: {
[validatorServiceName]: {
// Fee recipient is set as global env, keep this for backwards compatibility
["FEE_RECIPIENT_ADDRESS"]: defaultFeeRecipient,
// Graffiti is a mandatory value
["GRAFFITI"]: defaultDappnodeGraffiti,
},
? {
[validatorServiceName]: {
// Fee recipient is set as global env, keep this for backwards compatibility
["FEE_RECIPIENT_ADDRESS"]: defaultFeeRecipient,
// Graffiti is a mandatory value
["GRAFFITI"]: defaultDappnodeGraffiti,
},

[beaconServiceName]: {
// Fee recipient is set as global env, keep this for backwards compatibility
["FEE_RECIPIENT_ADDRESS"]: defaultFeeRecipient,
// Checkpoint sync is an optional value
["CHECKPOINT_SYNC_URL"]:
Consensus.DefaultCheckpointSync[network],
},
}
[beaconServiceName]: {
// Fee recipient is set as global env, keep this for backwards compatibility
["FEE_RECIPIENT_ADDRESS"]: defaultFeeRecipient,
// Checkpoint sync is an optional value
["CHECKPOINT_SYNC_URL"]:
Consensus.DefaultCheckpointSync[network],
},
}
: {},
networks: {
rootNetworks: {
Expand All @@ -187,68 +170,25 @@ export class Consensus extends StakerComponent {
},
},
serviceNetworks:
beaconServiceName === validatorServiceName
? {
"beacon-validator": {
[params.DOCKER_STAKER_NETWORKS[network]]: {
aliases: [
`beacon-chain.${network}.staker.dappnode`,
`validator.${network}.staker.dappnode`,
],
},
[params.DOCKER_PRIVATE_NETWORK_NAME]: {
aliases: [
`beacon-chain.${network}.dncore.dappnode`,
`validator.${network}.dncore.dappnode`,
],
},
},
}
: {
"beacon-chain": {
[params.DOCKER_STAKER_NETWORKS[network]]: {
aliases: [`beacon-chain.${network}.staker.dappnode`],
},
[params.DOCKER_PRIVATE_NETWORK_NAME]: {
aliases: [`beacon-chain.${network}.dncore.dappnode`],
},
},
validator: {
[params.DOCKER_STAKER_NETWORKS[network]]: {
aliases: [`validator.${network}.staker.dappnode`],
},
[params.DOCKER_PRIVATE_NETWORK_NAME]: {
aliases: [`validator.${network}.dncore.dappnode`],
},
},
},
{
"beacon-chain": {
[params.DOCKER_STAKER_NETWORKS[network]]: {
aliases: [`beacon-chain.${network}.staker.dappnode`],
},
[params.DOCKER_PRIVATE_NETWORK_NAME]: {
aliases: [`beacon-chain.${network}.dncore.dappnode`],
},
},
validator: {
[params.DOCKER_STAKER_NETWORKS[network]]: {
aliases: [`validator.${network}.staker.dappnode`],
},
[params.DOCKER_PRIVATE_NETWORK_NAME]: {
aliases: [`validator.${network}.dncore.dappnode`],
},
},
},
},
};
}

/**
* Get the validator service name.
* - Nimbus package is monoservice (beacon-validator)
* - Prysm, Teku, Lighthouse, and Lodestar are multiservice (beacon, validator)
*/
private getValidatorServiceName(newConsensusDnpName: string | null): string {
return newConsensusDnpName
? newConsensusDnpName.includes("nimbus")
? "beacon-validator"
: "validator"
: "";
}

/**
* Get the beacon service name
* - Nimbus package is monoservice (beacon-validator)
* - Prysm, Teku, Lighthouse, and Lodestar are multiservice (beacon, validator)
*/
private getBeaconServiceName(newConsensusDnpName: string | null): string {
return newConsensusDnpName
? newConsensusDnpName.includes("nimbus")
? "beacon-validator"
: "beacon-chain"
: "";
}
}
5 changes: 1 addition & 4 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export * from "./asyncFlows.js";
export * from "./pid.js";
export { urlJoin } from "./urlJoin.js";
export { prettyDnpName } from "./prettyDnpName.js";
export {
getBeaconServiceName,
getConsensusUserSettings,
} from "./stakerUtils.js";
export { getConsensusUserSettings } from "./stakerUtils.js";
export * from "./ethers.js";
export { shellSafe } from "./shellSafe.js";
export { getIsInstalled } from "./getIsInstalled.js";
Expand Down
Loading

0 comments on commit e8f2ed5

Please sign in to comment.