From ef4f6065d16ac78256be061be31b7b61dcbb14af Mon Sep 17 00:00:00 2001 From: pablomendezroyo Date: Wed, 30 Oct 2024 08:29:15 +0100 Subject: [PATCH] remove banned realays from mevboost pkg --- packages/migrations/src/index.ts | 10 +++++++++ packages/migrations/src/removeBannedRelays.ts | 22 +++++++++++++++++++ packages/stakers/src/mevBoost.ts | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 packages/migrations/src/removeBannedRelays.ts 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..4a733f2b8 --- /dev/null +++ b/packages/migrations/src/removeBannedRelays.ts @@ -0,0 +1,22 @@ +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" + ]; + for (const network of Object.values(Network)) { + const mevBoostDnpName = MevBoost.CompatibleMevBoost[network]?.dnpName; + if (mevBoostDnpName) { + const relays = await mevBoost.getMevBoostCurrentRelays(mevBoostDnpName); + const newRelays = relays.filter((relay) => !bannedRelays.includes(relay)); + if (newRelays.length !== relays.length) { + await mevBoost.setNewMevBoost(network, mevBoostDnpName, newRelays); + } + } + } +} diff --git a/packages/stakers/src/mevBoost.ts b/packages/stakers/src/mevBoost.ts index 9d57c65c1..935bcee48 100644 --- a/packages/stakers/src/mevBoost.ts +++ b/packages/stakers/src/mevBoost.ts @@ -15,7 +15,7 @@ export class MevBoost extends StakerComponent { [Network.Lukso]: db.mevBoostLukso }; - protected static readonly CompatibleMevBoost: Record = { + static readonly CompatibleMevBoost: Record = { [Network.Mainnet]: { dnpName: MevBoostMainnet.Mevboost, minVersion: "0.1.0"