Skip to content

Commit

Permalink
changes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 21, 2023
1 parent 0e3b652 commit 72a312c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ private BlockImportResult importBlockAndState(
blobSidecars,
earliestBlobSidecarsSlot);

if (applyProposerBoost(block, transaction)) {
if (shouldApplyProposerBoost(block, transaction)) {
transaction.setProposerBoostRoot(block.getRoot());
}

Expand Down Expand Up @@ -578,21 +578,25 @@ private BlockImportResult importBlockAndState(
return result;
}

private boolean applyProposerBoost(
// from consensus-specs/fork-choice:
// get_current_slot(store) == block.slot and is_before_attesting_interval and is_first_block
private boolean shouldApplyProposerBoost(
final SignedBeaconBlock block, final StoreTransaction transaction) {
if (spec.getCurrentSlot(transaction).equals(block.getSlot())) {
final UInt64 millisPerSlot = spec.getMillisPerSlot(block.getSlot());
final UInt64 timeIntoSlotMillis = getMillisIntoSlot(transaction, millisPerSlot);

if (isBeforeAttestingInterval(millisPerSlot, timeIntoSlotMillis)) {
if (forkChoiceProposerBoostUniquenessEnabled) {
// is_first_block
return recentChainData.getStore().getProposerBoostRoot().isEmpty();
}
return true;
}
if (!spec.getCurrentSlot(transaction).equals(block.getSlot())) {
return false;
}

final UInt64 millisPerSlot = spec.getMillisPerSlot(block.getSlot());
final UInt64 timeIntoSlotMillis = getMillisIntoSlot(transaction, millisPerSlot);
if (!isBeforeAttestingInterval(millisPerSlot, timeIntoSlotMillis)) {
return false;
}
return false;

if (forkChoiceProposerBoostUniquenessEnabled) {
return transaction.getProposerBoostRoot().isEmpty();
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,11 +1094,9 @@ private SignedBlockAndState generateMergeBlock() {
ZERO);
executionLayer.addPowBlock(terminalBlock);
executionLayer.addPowBlock(terminalParentBlock);
final SignedBlockAndState epoch4Block =
chainBuilder.generateBlockAtSlot(
storageSystem.chainUpdater().getHeadSlot().plus(1),
BlockOptions.create().setTerminalBlockHash(terminalBlockHash));
return epoch4Block;
return chainBuilder.generateBlockAtSlot(
storageSystem.chainUpdater().getHeadSlot().plus(1),
BlockOptions.create().setTerminalBlockHash(terminalBlockHash));
}

@Test
Expand Down

0 comments on commit 72a312c

Please sign in to comment.