Skip to content

Commit 6dd10cb

Browse files
authored
fix: do not trigger builder circuit breaker if clock slot < slots present (#7481)
**Motivation** We currently disable the builder flow for the most part of epoch 0 because the circuit breaker is triggered and we fall back to local block building. However the current check does not make much sense if there were not enough slots yet where proposal could be included on-chain. **Description** Do not trigger builder circuit breaker if clock slot < slots present (based on fork choice)
1 parent 7faa773 commit 6dd10cb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/beacon-node/src/chain/chain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ export class BeaconChain implements IBeaconChain {
12121212
const {faultInspectionWindow, allowedFaults} = executionBuilder;
12131213
const slotsPresent = this.forkChoice.getSlotsPresent(clockSlot - faultInspectionWindow);
12141214
const previousStatus = executionBuilder.status;
1215-
const shouldEnable = slotsPresent >= faultInspectionWindow - allowedFaults;
1215+
const shouldEnable = slotsPresent >= Math.min(faultInspectionWindow - allowedFaults, clockSlot);
12161216

12171217
executionBuilder.updateStatus(shouldEnable);
12181218
// The status changed we should log

packages/beacon-node/test/sim/mergemock.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ describe("executionEngine / ExecutionEngineHttp", () => {
9797
const epochsOfMargin = 1;
9898
const timeoutSetupMargin = 30 * 1000; // Give extra 30 seconds of margin
9999

100-
// The builder gets activated post middle of epoch because of circuit breaker
101-
// In a perfect run expected builder = 16, expected engine = 16
102-
// keeping 4 missed slots margin for both
103-
const expectedBuilderBlocks = 12;
104-
const expectedEngineBlocks = 12;
100+
// We only expect builder blocks since `builderalways` is configured
101+
// In a perfect run expected builder = 32, expected engine = 0
102+
// keeping 4 missed slots and 4 engine blocks due to fallback as margin
103+
const expectedBuilderBlocks = 28;
104+
const maximumEngineBlocks = 4;
105105

106106
// All assertions are tracked w.r.t. fee recipient by attaching different fee recipient to
107107
// execution and builder
@@ -264,9 +264,9 @@ describe("executionEngine / ExecutionEngineHttp", () => {
264264
throw Error(`Incorrect builderBlocks=${builderBlocks} (expected=${expectedBuilderBlocks})`);
265265
}
266266

267-
// 3. engine blocks are as expected
268-
if (engineBlocks < expectedEngineBlocks) {
269-
throw Error(`Incorrect engineBlocks=${engineBlocks} (expected=${expectedEngineBlocks})`);
267+
// 3. engine blocks do not exceed max limit
268+
if (engineBlocks > maximumEngineBlocks) {
269+
throw Error(`Incorrect engineBlocks=${engineBlocks} (limit=${maximumEngineBlocks})`);
270270
}
271271

272272
// wait for 1 slot to print current epoch stats

0 commit comments

Comments
 (0)