diff --git a/packages/brain/src/calls/getStakerConfig.ts b/packages/brain/src/calls/getStakerConfig.ts index f7208fd9..ceffa237 100644 --- a/packages/brain/src/calls/getStakerConfig.ts +++ b/packages/brain/src/calls/getStakerConfig.ts @@ -3,7 +3,6 @@ import { network, executionClient, consensusClient, - defaultFeeRecipient, executionClientUrl, validatorUrl, beaconchainUrl, @@ -19,6 +18,5 @@ export async function getStakerConfig(): Promise> { validatorUrl, beaconchainUrl, signerUrl, - defaultFeeRecipient, }; } diff --git a/packages/brain/src/index.ts b/packages/brain/src/index.ts index cdbd90e3..d7daf70e 100644 --- a/packages/brain/src/index.ts +++ b/packages/brain/src/index.ts @@ -33,11 +33,10 @@ export const { signerUrl, token, host, - defaultFeeRecipient, tlsCert, } = loadStakerConfig(); logger.debug( - `Loaded staker config:\n - Network: ${network}\n - Execution client: ${executionClient}\n - Consensus client: ${consensusClient}\n - Execution client url: ${executionClientUrl}\n - Validator url: ${validatorUrl}\n - Beaconcha url: ${beaconchaUrl}\n - Beaconchain url: ${beaconchainUrl}\n - Signer url: ${signerUrl}\n - Token: ${token}\n - Host: ${host}\n - Default fee recipient: ${defaultFeeRecipient}` + `Loaded staker config:\n - Network: ${network}\n - Execution client: ${executionClient}\n - Consensus client: ${consensusClient}\n - Execution client url: ${executionClientUrl}\n - Validator url: ${validatorUrl}\n - Beaconcha url: ${beaconchaUrl}\n - Beaconchain url: ${beaconchainUrl}\n - Signer url: ${signerUrl}\n - Token: ${token}\n - Host: ${host}}` ); // Create API instances. Must preceed db initialization @@ -68,7 +67,7 @@ export const brainDb = new BrainDataBase( const uiServer = startUiServer(path.resolve(__dirname, params.uiBuildDirName)); const launchpadServer = startLaunchpadApi(); -await brainDb.initialize(signerApi, validatorApi, defaultFeeRecipient); +await brainDb.initialize(signerApi, validatorApi); logger.debug(brainDb.data); // CRON diff --git a/packages/brain/src/modules/db/index.ts b/packages/brain/src/modules/db/index.ts index e1b0531f..31e063bd 100644 --- a/packages/brain/src/modules/db/index.ts +++ b/packages/brain/src/modules/db/index.ts @@ -59,19 +59,14 @@ export class BrainDataBase extends LowSync { */ public async initialize( signerApi: Web3SignerApi, - validatorApi: ValidatorApi, - defaultFeeRecipient: string | undefined + validatorApi: ValidatorApi ): Promise { try { // Important! .read() method must be called before accessing brainDb.data otherwise it will be null this.read(); // If db.json doesn't exist, db.data will be null if (this.data === null) - await this.databaseMigration( - signerApi, - validatorApi, - defaultFeeRecipient - ); + await this.databaseMigration(signerApi, validatorApi); else this.setOwnerWriteRead(); } catch (e) { logger.error(`unable to initialize the db ${this.dbName}`, e); @@ -247,12 +242,10 @@ export class BrainDataBase extends LowSync { * * @param signerApi - The signer API * @param validatorApi - The validator API - * @param defaultFeeRecipient - The default fee recipient to use if the validator API is not available */ private async databaseMigration( signerApi: Web3SignerApi, - validatorApi: ValidatorApi, - defaultFeeRecipient?: string + validatorApi: ValidatorApi ): Promise { let retries = 0; while (retries < 10) { @@ -279,11 +272,11 @@ export class BrainDataBase extends LowSync { }) .catch((e) => { logger.error( - `Unable to fetch fee recipient for ${pubkeys[0]}. Setting default ${defaultFeeRecipient}}`, + `Unable to fetch fee recipient for ${pubkeys[0]}. Setting default ${params.burnAddress}}`, e ); - if (defaultFeeRecipient) feeRecipient = defaultFeeRecipient; - else feeRecipient = params.burnAddress; + // TODO: consider setting MEV fee recipient. + feeRecipient = params.burnAddress; }); logger.info( diff --git a/packages/brain/src/modules/envs/index.ts b/packages/brain/src/modules/envs/index.ts index 77a5403e..3bcf36a1 100644 --- a/packages/brain/src/modules/envs/index.ts +++ b/packages/brain/src/modules/envs/index.ts @@ -28,7 +28,6 @@ import path from "path"; import fs from "fs"; import { params } from "../../params.js"; import { __dirname } from "../../index.js"; -import { isValidEcdsaPubkey } from "@stakingbrain/common"; /** * Loads the staker config needed to create the base urls for beacon, validator and signer APIs @@ -45,7 +44,7 @@ import { isValidEcdsaPubkey } from "@stakingbrain/common"; * @throws consensus client is not valid for : . Valid consensus clients for : * This exception is thrown if the consensus client is not valid for the network * - * @returns executionClientUrl, validatorUrl, beaconchainUrl, beaconchaUrl, signerUrl, token, host, defaultFeeRecipient, tlsCert + * @returns executionClientUrl, validatorUrl, beaconchainUrl, beaconchaUrl, signerUrl, token, host, tlsCert */ export function loadStakerConfig(): { network: Network; @@ -58,7 +57,6 @@ export function loadStakerConfig(): { signerUrl: string; token: string; host: string; - defaultFeeRecipient?: string; tlsCert?: Buffer; } { const network = process.env.NETWORK as Network; @@ -79,8 +77,7 @@ export function loadStakerConfig(): { tlsCert: Buffer | undefined; if (network === "mainnet") { - const { executionClient, consensusClient, defaultFeeRecipient } = - loadEnvs("mainnet"); + const { executionClient, consensusClient } = loadEnvs("mainnet"); switch (executionClient) { case "geth.dnp.dappnode.eth": executionClientUrl = `http://geth.dappnode:8545`; @@ -144,15 +141,10 @@ export function loadStakerConfig(): { signerUrl: `http://web3signer.web3signer.dappnode:9000`, token, host: `brain.web3signer.dappnode`, - defaultFeeRecipient: - defaultFeeRecipient && isValidEcdsaPubkey(defaultFeeRecipient) - ? defaultFeeRecipient - : undefined, tlsCert, }; } else if (network === "gnosis") { - const { executionClient, consensusClient, defaultFeeRecipient } = - loadEnvs("gnosis"); + const { executionClient, consensusClient } = loadEnvs("gnosis"); switch (executionClient) { case "nethermind-xdai.dnp.dappnode.eth": executionClientUrl = `http://nethermind-xdai.dappnode:8545`; @@ -202,15 +194,10 @@ export function loadStakerConfig(): { signerUrl: `http://web3signer.web3signer-gnosis.dappnode:9000`, token, host: `brain.web3signer-gnosis.dappnode`, - defaultFeeRecipient: - defaultFeeRecipient && isValidEcdsaPubkey(defaultFeeRecipient) - ? defaultFeeRecipient - : undefined, tlsCert, }; } else if (network === "prater") { - const { executionClient, consensusClient, defaultFeeRecipient } = - loadEnvs("prater"); + const { executionClient, consensusClient } = loadEnvs("prater"); switch (executionClient) { case "goerli-nethermind.dnp.dappnode.eth": executionClientUrl = `http://goerli-nethermind.dappnode:8545`; @@ -274,15 +261,10 @@ export function loadStakerConfig(): { signerUrl: `http://web3signer.web3signer-prater.dappnode:9000`, token, host: `web3signer.web3signer-prater.dappnode`, - defaultFeeRecipient: - defaultFeeRecipient && isValidEcdsaPubkey(defaultFeeRecipient) - ? defaultFeeRecipient - : undefined, tlsCert, }; } else if (network === "lukso") { - const { executionClient, consensusClient, defaultFeeRecipient } = - loadEnvs("lukso"); + const { executionClient, consensusClient } = loadEnvs("lukso"); switch (executionClient) { case "lukso-erigon.dnp.dappnode.eth": executionClientUrl = `http://lukso-erigon.dappnode:8545`; @@ -340,15 +322,10 @@ export function loadStakerConfig(): { signerUrl: `http://web3signer.web3signer-lukso.dappnode:9000`, token, host: `web3signer.web3signer-lukso.dappnode`, - defaultFeeRecipient: - defaultFeeRecipient && isValidEcdsaPubkey(defaultFeeRecipient) - ? defaultFeeRecipient - : undefined, tlsCert, }; } else if (network === "holesky") { - const { executionClient, consensusClient, defaultFeeRecipient } = - loadEnvs("holesky"); + const { executionClient, consensusClient } = loadEnvs("holesky"); switch (executionClient) { case "holesky-nethermind.dnp.dappnode.eth": executionClientUrl = `http://holesky-nethermind.dappnode:8545`; @@ -412,10 +389,6 @@ export function loadStakerConfig(): { signerUrl: `http://web3signer.web3signer-holesky.dappnode:9000`, token, host: `web3signer.web3signer-holesky.dappnode`, - defaultFeeRecipient: - defaultFeeRecipient && isValidEcdsaPubkey(defaultFeeRecipient) - ? defaultFeeRecipient - : undefined, tlsCert, }; } else { @@ -432,12 +405,9 @@ function loadEnvs( ): { executionClient: ExecutionClient; consensusClient: ConsensusClient; - defaultFeeRecipient?: string; } { const errors = []; - const defaultFeeRecipient = - process.env[`_DAPPNODE_GLOBAL_FEE_RECIPIENT_${network.toUpperCase()}`]; const executionClient = process.env[`_DAPPNODE_GLOBAL_EXECUTION_CLIENT_${network.toUpperCase()}`]; const consensusClient = @@ -564,6 +534,5 @@ function loadEnvs( return { executionClient: executionClient as ExecutionClient, consensusClient: consensusClient as ConsensusClient, - defaultFeeRecipient, }; } diff --git a/packages/brain/tests/unit/modules/db/index.unit.test.ts b/packages/brain/tests/unit/modules/db/index.unit.test.ts index 48f703b7..99a60597 100644 --- a/packages/brain/tests/unit/modules/db/index.unit.test.ts +++ b/packages/brain/tests/unit/modules/db/index.unit.test.ts @@ -98,11 +98,7 @@ describe("DataBase", () => { expect(db.data).to.be.null; // initialize - await db.initialize( - signerApi, - validatorApi, - "0x0000000000000000000000000000000000000000" - ); + await db.initialize(signerApi, validatorApi); // print contents of database console.log(db.data); // check database @@ -120,11 +116,7 @@ describe("DataBase", () => { const signerApi = sinon.createStubInstance(Web3SignerApi); const validatorApi = sinon.createStubInstance(ValidatorApi); sinon.stub(db, "databaseMigration").callsFake(databaseMigration); - await db.initialize( - signerApi, - validatorApi, - "0x0000000000000000000000000000000000000000" - ); + await db.initialize(signerApi, validatorApi); expect(fs.existsSync(testDbName)).to.be.true; db.read(); @@ -139,11 +131,7 @@ describe("DataBase", () => { fs.writeFileSync(testDbName, JSON.stringify({})); const signerApi = sinon.createStubInstance(Web3SignerApi); const validatorApi = sinon.createStubInstance(ValidatorApi); - db.initialize( - signerApi, - validatorApi, - "0x0000000000000000000000000000000000000000" - ); + db.initialize(signerApi, validatorApi); expect(fs.existsSync(testDbName)).to.be.true; db.read(); expect(db.data).to.be.empty; diff --git a/packages/common/src/types/network/types.ts b/packages/common/src/types/network/types.ts index 3f28b70d..8f41678f 100644 --- a/packages/common/src/types/network/types.ts +++ b/packages/common/src/types/network/types.ts @@ -10,7 +10,6 @@ export interface StakerConfig { validatorUrl: string; beaconchainUrl: string; signerUrl: string; - defaultFeeRecipient?: string; } export type ExecutionClient = T extends "mainnet"