Skip to content

Commit

Permalink
remove banned realays from mevboost pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Oct 30, 2024
1 parent 5457e78 commit ef4f606
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/migrations/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
22 changes: 22 additions & 0 deletions packages/migrations/src/removeBannedRelays.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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);
}
}
}
}
2 changes: 1 addition & 1 deletion packages/stakers/src/mevBoost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MevBoost extends StakerComponent {
[Network.Lukso]: db.mevBoostLukso
};

protected static readonly CompatibleMevBoost: Record<Network, { dnpName: string; minVersion: string } | null> = {
static readonly CompatibleMevBoost: Record<Network, { dnpName: string; minVersion: string } | null> = {
[Network.Mainnet]: {
dnpName: MevBoostMainnet.Mevboost,
minVersion: "0.1.0"
Expand Down

0 comments on commit ef4f606

Please sign in to comment.