mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-09 15:48:08 -05:00
fix: don't log proposer boost reorg logs during sync (#8363)
**Motivation** We currently print proposer boost reorg related logs `Strong block detected ...` during sync but it's not relevant there as `shouldOverrideForkChoiceUpdate` will never return true if `block.slot < currentSlot`. There is also an edge we currently don't handle since we only run proposer reorg checks if block is received through gossip but in theory (although unlikely in practice) we can also receive the block via req/resp (close to 0% on mainnet). **Description** - only run proposer boost reorg check if `block.slot >= currentSlot` - do not emit logs if no checks are run, eg. during sync there is no reason to emit logs - remove `isGossipBlock` flag to also check if receive block via req/resp, this also means we run the checks if receive block from api meaning we a previous proposer, we could additional check if we are previous proposer cache if we wanna handle that case explicitly
This commit is contained in:
@@ -80,7 +80,8 @@ export async function importBlock(
|
||||
const {slot: blockSlot} = block.message;
|
||||
const blockRoot = this.config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(block.message);
|
||||
const blockRootHex = toRootHex(blockRoot);
|
||||
const currentEpoch = computeEpochAtSlot(this.forkChoice.getTime());
|
||||
const currentSlot = this.forkChoice.getTime();
|
||||
const currentEpoch = computeEpochAtSlot(currentSlot);
|
||||
const blockEpoch = computeEpochAtSlot(blockSlot);
|
||||
const prevFinalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
|
||||
const blockDelaySec = (fullyVerifiedBlock.seenTimestampSec - postState.genesisTime) % this.config.SECONDS_PER_SLOT;
|
||||
@@ -106,7 +107,7 @@ export async function importBlock(
|
||||
block.message,
|
||||
postState,
|
||||
blockDelaySec,
|
||||
this.clock.currentSlot,
|
||||
currentSlot,
|
||||
executionStatus,
|
||||
dataAvailabilityStatus
|
||||
);
|
||||
@@ -326,14 +327,13 @@ export async function importBlock(
|
||||
// Suppress fcu call if shouldOverrideFcu is true. This only happens if we have proposer boost reorg enabled
|
||||
// and the block is weak and can potentially be reorged out.
|
||||
let shouldOverrideFcu = false;
|
||||
let notOverrideFcuReason = NotReorgedReason.Unknown;
|
||||
|
||||
if (opts.isGossipBlock && isExecutionStateType(postState)) {
|
||||
if (blockSlot >= currentSlot && isExecutionStateType(postState)) {
|
||||
let notOverrideFcuReason = NotReorgedReason.Unknown;
|
||||
const proposalSlot = blockSlot + 1;
|
||||
try {
|
||||
const proposerIndex = postState.epochCtx.getBeaconProposer(proposalSlot);
|
||||
const feeRecipient = this.beaconProposerCache.get(proposerIndex);
|
||||
const {currentSlot} = this.clock;
|
||||
|
||||
if (feeRecipient) {
|
||||
// We would set this to true if
|
||||
@@ -360,20 +360,20 @@ export async function importBlock(
|
||||
this.logger.warn("Unable to get beacon proposer. Do not override fcu.", {proposalSlot}, e as Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldOverrideFcu) {
|
||||
this.logger.verbose("Weak block detected. Skip fcu call in importBlock", {
|
||||
blockRoot: blockRootHex,
|
||||
slot: blockSlot,
|
||||
});
|
||||
} else {
|
||||
this.metrics?.importBlock.notOverrideFcuReason.inc({reason: notOverrideFcuReason});
|
||||
this.logger.verbose("Strong block detected. Not override fcu call", {
|
||||
blockRoot: blockRootHex,
|
||||
slot: blockSlot,
|
||||
reason: notOverrideFcuReason,
|
||||
});
|
||||
if (shouldOverrideFcu) {
|
||||
this.logger.verbose("Weak block detected. Skip fcu call in importBlock", {
|
||||
blockRoot: blockRootHex,
|
||||
slot: blockSlot,
|
||||
});
|
||||
} else {
|
||||
this.metrics?.importBlock.notOverrideFcuReason.inc({reason: notOverrideFcuReason});
|
||||
this.logger.verbose("Strong block detected. Not override fcu call", {
|
||||
blockRoot: blockRootHex,
|
||||
slot: blockSlot,
|
||||
reason: notOverrideFcuReason,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -460,7 +460,7 @@ export async function importBlock(
|
||||
|
||||
// Send block events, only for recent enough blocks
|
||||
|
||||
if (this.clock.currentSlot - blockSlot < EVENTSTREAM_EMIT_RECENT_BLOCK_SLOTS) {
|
||||
if (currentSlot - blockSlot < EVENTSTREAM_EMIT_RECENT_BLOCK_SLOTS) {
|
||||
// We want to import block asap so call all event handler in the next event loop
|
||||
callInNextEventLoop(() => {
|
||||
// NOTE: Skip emitting if there are no listeners from the API
|
||||
|
||||
@@ -285,8 +285,6 @@ export type ImportBlockOpts = {
|
||||
seenTimestampSec?: number;
|
||||
/** Set to true if persist block right at verification time */
|
||||
eagerPersistBlock?: boolean;
|
||||
/** Set to true if the importing block is from gossip */
|
||||
isGossipBlock?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -386,7 +386,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
||||
seenTimestampSec,
|
||||
// gossip block is validated, we want to process it asap
|
||||
eagerPersistBlock: true,
|
||||
isGossipBlock: true,
|
||||
})
|
||||
.then(() => {
|
||||
// Returns the delay between the start of `block.slot` and `current time`
|
||||
|
||||
Reference in New Issue
Block a user