diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts index 78c50cf6e..9db9df74d 100644 --- a/packages/migrations/src/index.ts +++ b/packages/migrations/src/index.ts @@ -12,6 +12,7 @@ import { changeEthicalMetricsDbFormat } from "./changeEthicalMetricsDbFormat.js" import { createStakerNetworkAndConnectStakerPkgs } from "./createStakerNetworkAndConnectStakerPkgs.js"; import { determineIsDappnodeAws } from "./determineIsDappnodeAws.js"; import { Consensus, Execution, MevBoost, Signer } from "@dappnode/stakers"; +import { removeBannedRelays } from "./removeBannedRelays.js"; export class MigrationError extends Error { migration: string; @@ -151,5 +152,14 @@ export async function executeMigrations( }) ); + await removeBannedRelays(mevBoost).catch((e) => + migrationErrors.push({ + migration: "remove banned relays from the mevboost package", + coreVersion: "0.2.99", + name: "MIGRATION_ERROR", + message: e + }) + ); + if (migrationErrors.length > 0) throw migrationErrors; } diff --git a/packages/migrations/src/removeBannedRelays.ts b/packages/migrations/src/removeBannedRelays.ts new file mode 100644 index 000000000..37d061c9f --- /dev/null +++ b/packages/migrations/src/removeBannedRelays.ts @@ -0,0 +1,21 @@ +import { logs } from "@dappnode/logger"; +import { MevBoost } from "@dappnode/stakers"; +import { Network } from "@dappnode/types"; + +/** + * Checks for banned relays in the mevboost package enviroment variable RELAYS + * and removes them from the list if they are present. Then restarts the mevboost package. + */ +export async function removeBannedRelays(mevBoost: MevBoost): Promise { + const bannedRelays = [ + "https://0xb3ee7afcf27f1f1259ac1787876318c6584ee353097a50ed84f51a1f21a323b3736f271a895c7ce918c038e4265918be@relay.edennetwork.io" + ]; + const mevBoostDnpName = "mevboost.dnp.dappnode.eth"; + + const relays = await mevBoost.getMevBoostCurrentRelays(mevBoostDnpName); + const newRelays = relays.filter((relay) => !bannedRelays.includes(relay)); + if (newRelays.length !== relays.length) { + logs.info(`Removing banned relays: ${bannedRelays.filter((relay) => !newRelays.includes(relay))}`); + await mevBoost.setNewMevBoost(Network.Mainnet, mevBoostDnpName, newRelays); + } +}