Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove banned realays from mevboost pkg #2052

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
21 changes: 21 additions & 0 deletions packages/migrations/src/removeBannedRelays.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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);
}
}
Loading