diff --git a/lerna.json b/lerna.json index a9c5000b24f5..b07dd9032eec 100644 --- a/lerna.json +++ b/lerna.json @@ -5,7 +5,7 @@ "npmClient": "yarn", "useWorkspaces": true, "useNx": true, - "version": "1.9.1", + "version": "1.9.2", "stream": "true", "command": { "version": { diff --git a/packages/api/package.json b/packages/api/package.json index a1d215983693..9d0e54ac0a4b 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -71,10 +71,10 @@ "dependencies": { "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/ssz": "^0.10.2", - "@lodestar/config": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/config": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", "cross-fetch": "^3.1.4", "eventsource": "^2.0.2", "qs": "^6.11.1" diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index 16e2f67ed117..abaa35821596 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -118,18 +118,18 @@ "@libp2p/peer-id-factory": "^2.0.1", "@libp2p/prometheus-metrics": "^1.1.3", "@libp2p/tcp": "6.1.0", - "@lodestar/api": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/db": "^1.9.1", - "@lodestar/fork-choice": "^1.9.1", - "@lodestar/light-client": "^1.9.1", - "@lodestar/logger": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/reqresp": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", - "@lodestar/validator": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/db": "^1.9.2", + "@lodestar/fork-choice": "^1.9.2", + "@lodestar/light-client": "^1.9.2", + "@lodestar/logger": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/reqresp": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", + "@lodestar/validator": "^1.9.2", "@multiformats/multiaddr": "^11.0.0", "@types/datastore-level": "^3.0.0", "buffer-xor": "^2.0.2", diff --git a/packages/beacon-node/src/sync/unknownBlock.ts b/packages/beacon-node/src/sync/unknownBlock.ts index 32d8070c4fa3..37097d38b116 100644 --- a/packages/beacon-node/src/sync/unknownBlock.ts +++ b/packages/beacon-node/src/sync/unknownBlock.ts @@ -57,21 +57,23 @@ export class UnknownBlockSync { if (!this.opts?.disableUnknownBlockSync) { // cannot chain to the above if or the log will be incorrect if (!this.subscribedToNetworkEvents) { - this.logger.debug("UnknownBlockSync enabled."); + this.logger.verbose("UnknownBlockSync enabled."); this.network.events.on(NetworkEvent.unknownBlock, this.onUnknownBlock); this.network.events.on(NetworkEvent.unknownBlockParent, this.onUnknownParent); this.network.events.on(NetworkEvent.peerConnected, this.triggerUnknownBlockSearch); this.subscribedToNetworkEvents = true; } } else { - this.logger.debug("UnknownBlockSync disabled."); + this.logger.verbose("UnknownBlockSync disabled by disableUnknownBlockSync option."); } } unsubscribeFromNetwork(): void { + this.logger.verbose("UnknownBlockSync disabled."); this.network.events.off(NetworkEvent.unknownBlock, this.onUnknownBlock); this.network.events.off(NetworkEvent.unknownBlockParent, this.onUnknownParent); this.network.events.off(NetworkEvent.peerConnected, this.triggerUnknownBlockSearch); + this.subscribedToNetworkEvents = false; } close(): void { diff --git a/packages/beacon-node/test/unit/sync/unknownBlock.test.ts b/packages/beacon-node/test/unit/sync/unknownBlock.test.ts index 6086ee732858..f13902ad4928 100644 --- a/packages/beacon-node/test/unit/sync/unknownBlock.test.ts +++ b/packages/beacon-node/test/unit/sync/unknownBlock.test.ts @@ -1,12 +1,13 @@ +import EventEmitter from "node:events"; import {expect} from "chai"; -import sinon from "sinon"; +import sinon, {SinonStubbedInstance} from "sinon"; +import {toHexString} from "@chainsafe/ssz"; import {config as minimalConfig} from "@lodestar/config/default"; import {createChainForkConfig} from "@lodestar/config"; import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {ssz} from "@lodestar/types"; import {notNullish, sleep} from "@lodestar/utils"; -import {toHexString} from "@chainsafe/ssz"; -import {IBeaconChain} from "../../../src/chain/index.js"; +import {BeaconChain, IBeaconChain} from "../../../src/chain/index.js"; import {INetwork, NetworkEvent, NetworkEventBus, PeerAction} from "../../../src/network/index.js"; import {UnknownBlockSync} from "../../../src/sync/unknownBlock.js"; import {testLogger} from "../../utils/logger.js"; @@ -17,7 +18,7 @@ import {SeenBlockProposers} from "../../../src/chain/seenCache/seenBlockProposer import {BlockError, BlockErrorCode} from "../../../src/chain/errors/blockError.js"; import {defaultSyncOptions} from "../../../src/sync/options.js"; -describe("sync / UnknownBlockSync", () => { +describe("sync by UnknownBlockSync", () => { const logger = testLogger(); const sandbox = sinon.createSandbox(); const slotSec = 0.3; @@ -226,3 +227,61 @@ describe("sync / UnknownBlockSync", () => { }); } }); + +describe("UnknownBlockSync", function () { + const sandbox = sinon.createSandbox(); + let network: INetwork; + let chain: SinonStubbedInstance & IBeaconChain; + const logger = testLogger(); + let service: UnknownBlockSync; + + beforeEach(() => { + network = { + events: new NetworkEventBus(), + } as Partial as INetwork; + chain = sandbox.createStubInstance(BeaconChain); + }); + + afterEach(() => { + sandbox.restore(); + }); + + const testCases: {actions: boolean[]; expected: boolean}[] = [ + // true = subscribe, false = unsubscribe + // expected = isSubscribed + {actions: [false, true], expected: true}, + {actions: [false, true, true], expected: true}, + {actions: [true, false, true], expected: true}, + {actions: [true, true, true], expected: true}, + {actions: [true, false, false, true], expected: true}, + {actions: [true, false], expected: false}, + {actions: [true, false, false], expected: false}, + ]; + + describe("subscribe and unsubscribe multiple times", () => { + for (const {actions, expected} of testCases) { + const testName = actions.map((action) => (action ? "subscribe" : "unsubscribe")).join(" - "); + it(testName, () => { + const events = network.events as EventEmitter; + service = new UnknownBlockSync(minimalConfig, network, chain, logger, null, defaultSyncOptions); + for (const action of actions) { + if (action) { + service.subscribeToNetwork(); + } else { + service.unsubscribeFromNetwork(); + } + } + + if (expected) { + expect(events.listenerCount(NetworkEvent.unknownBlock)).to.be.equal(1); + expect(events.listenerCount(NetworkEvent.unknownBlockParent)).to.be.equal(1); + expect(service.isSubscribedToNetwork()).to.be.true; + } else { + expect(events.listenerCount(NetworkEvent.unknownBlock)).to.be.equal(0); + expect(events.listenerCount(NetworkEvent.unknownBlockParent)).to.be.equal(0); + expect(service.isSubscribedToNetwork()).to.be.false; + } + }); + } + }); +}); diff --git a/packages/cli/package.json b/packages/cli/package.json index 1d4d29d5ee9b..6d20485e0bbb 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@chainsafe/lodestar", - "version": "1.9.1", + "version": "1.9.2", "description": "Command line interface for lodestar", "author": "ChainSafe Systems", "license": "LGPL-3.0", @@ -60,17 +60,17 @@ "@chainsafe/discv5": "^3.0.0", "@chainsafe/ssz": "^0.10.2", "@libp2p/peer-id-factory": "^2.0.3", - "@lodestar/api": "^1.9.1", - "@lodestar/beacon-node": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/db": "^1.9.1", - "@lodestar/light-client": "^1.9.1", - "@lodestar/logger": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", - "@lodestar/validator": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/beacon-node": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/db": "^1.9.2", + "@lodestar/light-client": "^1.9.2", + "@lodestar/logger": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", + "@lodestar/validator": "^1.9.2", "@multiformats/multiaddr": "^11.0.0", "@types/lockfile": "^1.0.2", "bip39": "^3.1.0", diff --git a/packages/cli/src/cmds/validator/handler.ts b/packages/cli/src/cmds/validator/handler.ts index 305e101f5287..c0f8e6babdc2 100644 --- a/packages/cli/src/cmds/validator/handler.ts +++ b/packages/cli/src/cmds/validator/handler.ts @@ -254,6 +254,8 @@ function parseBuilderSelection(builderSelection?: string): BuilderSelection | un break; case "builderalways": break; + case "builderonly": + break; default: throw Error("Invalid input for builder selection, check help."); } diff --git a/packages/cli/src/cmds/validator/options.ts b/packages/cli/src/cmds/validator/options.ts index 3dd0d7d9505d..f92814cdcb3d 100644 --- a/packages/cli/src/cmds/validator/options.ts +++ b/packages/cli/src/cmds/validator/options.ts @@ -237,7 +237,7 @@ export const validatorOptions: CliCommandOptions = { "builder.selection": { type: "string", - description: "Default builder block selection strategy: maxprofit or builderalways", + description: "Default builder block selection strategy: maxprofit, builderalways, or builderonly", defaultDescription: `${defaultOptions.builderSelection}`, group: "builder", }, diff --git a/packages/config/package.json b/packages/config/package.json index 21ec07edacb0..de2ca71d577b 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/config", - "version": "1.9.1", + "version": "1.9.2", "description": "Chain configuration required for lodestar", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -65,7 +65,7 @@ ], "dependencies": { "@chainsafe/ssz": "^0.10.2", - "@lodestar/params": "^1.9.1", - "@lodestar/types": "^1.9.1" + "@lodestar/params": "^1.9.2", + "@lodestar/types": "^1.9.2" } } diff --git a/packages/db/package.json b/packages/db/package.json index ccabf40e3efc..415d01afeb61 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/db", - "version": "1.9.1", + "version": "1.9.2", "description": "DB modules of Lodestar", "author": "ChainSafe Systems", "homepage": "https://github.com/ChainSafe/lodestar#readme", @@ -38,13 +38,13 @@ }, "dependencies": { "@chainsafe/ssz": "^0.10.2", - "@lodestar/config": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/config": "^1.9.2", + "@lodestar/utils": "^1.9.2", "@types/levelup": "^4.3.3", "it-all": "^3.0.1", "level": "^8.0.0" }, "devDependencies": { - "@lodestar/logger": "^1.9.1" + "@lodestar/logger": "^1.9.2" } } diff --git a/packages/flare/package.json b/packages/flare/package.json index 3e2780c7bae1..4ecf7f8556e0 100644 --- a/packages/flare/package.json +++ b/packages/flare/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/flare", - "version": "1.9.1", + "version": "1.9.2", "description": "Beacon chain debugging tool", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -58,10 +58,10 @@ "blockchain" ], "dependencies": { - "@lodestar/api": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", "source-map-support": "^0.5.21", "yargs": "^17.7.1" }, diff --git a/packages/fork-choice/package.json b/packages/fork-choice/package.json index 8ab522311962..f80dd051a537 100644 --- a/packages/fork-choice/package.json +++ b/packages/fork-choice/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": "./lib/index.js", "types": "./lib/index.d.ts", @@ -39,11 +39,11 @@ }, "dependencies": { "@chainsafe/ssz": "^0.10.2", - "@lodestar/config": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1" + "@lodestar/config": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2" }, "keywords": [ "ethereum", diff --git a/packages/light-client/package.json b/packages/light-client/package.json index 61c685517e6c..161653bbb66c 100644 --- a/packages/light-client/package.json +++ b/packages/light-client/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -67,12 +67,12 @@ "@chainsafe/bls": "7.1.1", "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/ssz": "^0.10.2", - "@lodestar/api": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", "cross-fetch": "^3.1.4", "mitt": "^3.0.0", "strict-event-emitter-types": "^2.0.0" diff --git a/packages/logger/package.json b/packages/logger/package.json index ad1c8709ba54..f51202f27b07 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -61,7 +61,7 @@ }, "types": "lib/index.d.ts", "dependencies": { - "@lodestar/utils": "^1.9.1", + "@lodestar/utils": "^1.9.2", "winston": "^3.8.2", "winston-daily-rotate-file": "^4.7.1", "winston-transport": "^4.5.0" diff --git a/packages/params/package.json b/packages/params/package.json index e2d696b75b85..57698dcb008e 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/params", - "version": "1.9.1", + "version": "1.9.2", "description": "Chain parameters required for lodestar", "author": "ChainSafe Systems", "license": "Apache-2.0", diff --git a/packages/prover/package.json b/packages/prover/package.json index e060e3abb28d..ad1c9daaa9a2 100644 --- a/packages/prover/package.json +++ b/packages/prover/package.json @@ -12,7 +12,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -68,11 +68,11 @@ "@ethereumjs/tx": "^4.1.2", "@ethereumjs/util": "^8.0.6", "@ethereumjs/vm": "^6.4.2", - "@lodestar/api": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/light-client": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/light-client": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", "ethereum-cryptography": "^1.2.0", "find-up": "^6.3.0", "http-proxy": "^1.18.1", @@ -82,7 +82,7 @@ "yargs": "^17.7.1" }, "devDependencies": { - "@lodestar/logger": "^1.9.1", + "@lodestar/logger": "^1.9.2", "@types/http-proxy": "^1.17.10", "@types/yargs": "^17.0.24", "axios": "^1.3.4", diff --git a/packages/reqresp/package.json b/packages/reqresp/package.json index 4ae00a77cc3f..be356003a322 100644 --- a/packages/reqresp/package.json +++ b/packages/reqresp/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -57,9 +57,9 @@ "@chainsafe/snappy-stream": "^5.1.2", "@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-peer-id": "^2.0.1", - "@lodestar/config": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/config": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/utils": "^1.9.2", "it-all": "^3.0.1", "snappyjs": "^0.7.0", "stream-to-it": "^0.2.4", @@ -67,8 +67,8 @@ "varint": "^6.0.0" }, "devDependencies": { - "@lodestar/logger": "^1.9.1", - "@lodestar/types": "^1.9.1" + "@lodestar/logger": "^1.9.2", + "@lodestar/types": "^1.9.2" }, "peerDependencies": { "libp2p": "~0.42.2" diff --git a/packages/spec-test-util/package.json b/packages/spec-test-util/package.json index 7c83c580123a..58409fc8414c 100644 --- a/packages/spec-test-util/package.json +++ b/packages/spec-test-util/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/spec-test-util", - "version": "1.9.1", + "version": "1.9.2", "description": "Spec test suite generator from yaml test files", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -45,7 +45,7 @@ "blockchain" ], "dependencies": { - "@lodestar/utils": "^1.9.1", + "@lodestar/utils": "^1.9.2", "async-retry": "^1.3.3", "axios": "^1.3.4", "chai": "^4.3.7", diff --git a/packages/state-transition/package.json b/packages/state-transition/package.json index c8f16481adbe..c658f22c26ae 100644 --- a/packages/state-transition/package.json +++ b/packages/state-transition/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -62,10 +62,10 @@ "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/persistent-ts": "^0.19.1", "@chainsafe/ssz": "^0.10.2", - "@lodestar/config": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/config": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", "bigint-buffer": "^1.1.5", "buffer-xor": "^2.0.2" }, diff --git a/packages/types/package.json b/packages/types/package.json index dd9b31d1ab43..b5203891cf96 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": { ".": { @@ -68,7 +68,7 @@ "types": "lib/index.d.ts", "dependencies": { "@chainsafe/ssz": "^0.10.2", - "@lodestar/params": "^1.9.1" + "@lodestar/params": "^1.9.2" }, "keywords": [ "ethereum", diff --git a/packages/utils/package.json b/packages/utils/package.json index 270f941d7e6a..ad4349e6cbbd 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.9.1", + "version": "1.9.2", "type": "module", "exports": "./lib/index.js", "files": [ diff --git a/packages/validator/package.json b/packages/validator/package.json index 1b20eb5db607..0a12d3080120 100644 --- a/packages/validator/package.json +++ b/packages/validator/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/validator", - "version": "1.9.1", + "version": "1.9.2", "description": "A Typescript implementation of the validator client", "author": "ChainSafe Systems", "license": "LGPL-3.0", @@ -50,13 +50,13 @@ "dependencies": { "@chainsafe/bls": "7.1.1", "@chainsafe/ssz": "^0.10.2", - "@lodestar/api": "^1.9.1", - "@lodestar/config": "^1.9.1", - "@lodestar/db": "^1.9.1", - "@lodestar/params": "^1.9.1", - "@lodestar/state-transition": "^1.9.1", - "@lodestar/types": "^1.9.1", - "@lodestar/utils": "^1.9.1", + "@lodestar/api": "^1.9.2", + "@lodestar/config": "^1.9.2", + "@lodestar/db": "^1.9.2", + "@lodestar/params": "^1.9.2", + "@lodestar/state-transition": "^1.9.2", + "@lodestar/types": "^1.9.2", + "@lodestar/utils": "^1.9.2", "bigint-buffer": "^1.1.5", "cross-fetch": "^3.1.4", "strict-event-emitter-types": "^2.0.0" diff --git a/packages/validator/src/services/block.ts b/packages/validator/src/services/block.ts index bb2d230e0321..29f3bb5588b8 100644 --- a/packages/validator/src/services/block.ts +++ b/packages/validator/src/services/block.ts @@ -38,8 +38,12 @@ const MAX_DECIMAL_FACTOR = BigInt("100000"); /** * Cutoff time to wait for execution and builder block production apis to resolve * Post this time, race execution and builder to pick whatever resolves first + * + * Emprically the builder block resolves in ~1.5+ seconds, and executon should resolve <1 sec. + * So lowering the cutoff to 2 sec from 3 seconds to publish faster for successful proposal + * as proposals post 4 seconds into the slot seems to be not being included */ -const BLOCK_PRODUCTION_RACE_CUTOFF_MS = 3_000; +const BLOCK_PRODUCTION_RACE_CUTOFF_MS = 2_000; /** Overall timeout for execution and block production apis */ const BLOCK_PRODUCTION_RACE_TIMEOUT_MS = 12_000; @@ -109,14 +113,20 @@ export class BlockProposingService { const debugLogCtx = {...logCtx, validator: pubkeyHex}; - this.logger.debug("Producing block", debugLogCtx); - this.metrics?.proposerStepCallProduceBlock.observe(this.clock.secFromSlot(slot)); - const strictFeeRecipientCheck = this.validatorStore.strictFeeRecipientCheck(pubkeyHex); const isBuilderEnabled = this.validatorStore.isBuilderEnabled(pubkeyHex); const builderSelection = this.validatorStore.getBuilderSelection(pubkeyHex); const expectedFeeRecipient = this.validatorStore.getFeeRecipient(pubkeyHex); + this.logger.debug("Producing block", { + ...debugLogCtx, + isBuilderEnabled, + builderSelection, + expectedFeeRecipient, + strictFeeRecipientCheck, + }); + this.metrics?.proposerStepCallProduceBlock.observe(this.clock.secFromSlot(slot)); + const blockContents = await this.produceBlockWrapper(slot, randaoReveal, graffiti, { expectedFeeRecipient, strictFeeRecipientCheck, @@ -190,10 +200,20 @@ export class BlockProposingService { > => { // Start calls for building execution and builder blocks const blindedBlockPromise = isBuilderEnabled ? this.produceBlindedBlock(slot, randaoReveal, graffiti) : null; - const fullBlockPromise = this.produceBlock(slot, randaoReveal, graffiti); + const fullBlockPromise = + // At any point either the builder or execution or both flows should be active. + // + // Ideally such a scenario should be prevented on startup, but proposerSettingsFile or keymanager + // configurations could cause a validator pubkey to have builder disabled with builder selection builder only + // (TODO: independently make sure such an options update is not successful for a validator pubkey) + // + // So if builder is disabled ignore builder selection of builderonly if caused by user mistake + !isBuilderEnabled || builderSelection !== BuilderSelection.BuilderOnly + ? this.produceBlock(slot, randaoReveal, graffiti) + : null; let blindedBlock, fullBlock; - if (blindedBlockPromise !== null) { + if (blindedBlockPromise !== null && fullBlockPromise !== null) { // reference index of promises in the race const promisesOrder = [ProducedBlockSource.builder, ProducedBlockSource.engine]; [blindedBlock, fullBlock] = await racePromisesWithCutoff<{ @@ -225,9 +245,16 @@ export class BlockProposingService { this.logger.error("Failed to produce execution block", {}, fullBlock); fullBlock = null; } - } else { - fullBlock = await fullBlockPromise; + } else if (blindedBlockPromise !== null && fullBlockPromise === null) { + blindedBlock = await blindedBlockPromise; + fullBlock = null; + } else if (blindedBlockPromise === null && fullBlockPromise !== null) { blindedBlock = null; + fullBlock = await fullBlockPromise; + } else { + throw Error( + `Internal Error: Neither builder nor execution proposal flow activated isBuilderEnabled=${isBuilderEnabled} builderSelection=${builderSelection}` + ); } const builderBlockValue = blindedBlock?.blockValue ?? BigInt(0); @@ -252,7 +279,7 @@ export class BlockProposingService { break; } - case BuilderSelection.BuilderAlways: + // For everything else just select the builder default: { selectedSource = ProducedBlockSource.builder; selectedBlock = blindedBlock; diff --git a/packages/validator/src/services/validatorStore.ts b/packages/validator/src/services/validatorStore.ts index 0dbd9077257b..d2fe36b1e214 100644 --- a/packages/validator/src/services/validatorStore.ts +++ b/packages/validator/src/services/validatorStore.ts @@ -67,6 +67,8 @@ export type SignerRemote = { export enum BuilderSelection { BuilderAlways = "builderalways", MaxProfit = "maxprofit", + /** Only activate builder flow for DVT block proposal protocols */ + BuilderOnly = "builderonly", } type DefaultProposerConfig = {