Skip to content

Commit

Permalink
fix assemble
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Nov 10, 2024
1 parent 3cd5c22 commit 52bb222
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.forkchoice.ChildNode;
import tech.pegasys.teku.spec.datastructures.forkchoice.ProtoNodeData;
import tech.pegasys.teku.spec.datastructures.forkchoice.ReadOnlyForkChoiceStrategy;
import tech.pegasys.teku.spec.datastructures.operations.AttestationData;
Expand Down Expand Up @@ -162,7 +163,7 @@ public SafeFuture<Optional<BeaconState>> getStateToValidate(
final ReadOnlyForkChoiceStrategy forkChoiceStrategy =
recentChainData.getForkChoiceStrategy().orElseThrow();
final Optional<Bytes32> maybeAncestorRoot =
forkChoiceStrategy.getAncestor(targetBlockRoot, earliestSlot);
forkChoiceStrategy.getAncestor(targetBlockRoot, earliestSlot).map(ChildNode::root);
if (maybeAncestorRoot.isEmpty()) {
// The target block has become unknown or doesn't extend from finalized anymore
// so we can now ignore it.
Expand Down Expand Up @@ -196,6 +197,7 @@ private Boolean isAncestorOfChainHead(
.getForkChoiceStrategy()
.orElseThrow()
.getAncestor(headRoot, blockSlot)
.map(ChildNode::root)
.map(canonicalRoot -> canonicalRoot.equals(blockRoot))
.orElse(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.forkchoice.ChildNode;
import tech.pegasys.teku.spec.datastructures.forkchoice.ReadOnlyForkChoiceStrategy;
import tech.pegasys.teku.spec.datastructures.state.Checkpoint;
import tech.pegasys.teku.spec.datastructures.state.CheckpointState;
Expand Down Expand Up @@ -569,7 +570,7 @@ private void mockForkChoice(final List<SignedBeaconBlock> blocks) {
when(forkChoiceStrategy.blockParentRoot(block.getRoot()))
.thenReturn(Optional.of(block.getParentRoot()));
when(forkChoiceStrategy.getAncestor(any(), eq(block.getSlot())))
.thenReturn(Optional.of(block.getRoot()));
.thenReturn(Optional.of(new ChildNode(block.getRoot(), block.getSlot(), false)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState;
import tech.pegasys.teku.spec.datastructures.blocks.SlotAndBlockRoot;
import tech.pegasys.teku.spec.datastructures.forkchoice.ChildNode;
import tech.pegasys.teku.spec.datastructures.forkchoice.ProtoNodeData;
import tech.pegasys.teku.spec.datastructures.forkchoice.ProtoNodeValidationStatus;
import tech.pegasys.teku.spec.datastructures.forkchoice.ReadOnlyForkChoiceStrategy;
Expand Down Expand Up @@ -184,7 +185,7 @@ void getAncestor_specifiedBlockIsAtSlot() {
final SignedBlockAndState block = storageSystem.chainUpdater().addNewBestBlock();
final ForkChoiceStrategy protoArrayStrategy = getProtoArray(storageSystem);
assertThat(protoArrayStrategy.getAncestor(block.getRoot(), block.getSlot()))
.contains(block.getRoot());
.contains(new ChildNode(block.getRoot(), block.getSlot(), false));
}

@Test
Expand Down Expand Up @@ -220,7 +221,7 @@ void getAncestor_ancestorIsFound() {
final SignedBlockAndState head = storageSystem.chainUpdater().advanceChain(5);
final ForkChoiceStrategy protoArrayStrategy = getProtoArray(storageSystem);
assertThat(protoArrayStrategy.getAncestor(head.getRoot(), ancestor.getSlot()))
.contains(ancestor.getRoot());
.contains(new ChildNode(ancestor.getRoot(), ancestor.getSlot(), false));
}

@Test
Expand Down Expand Up @@ -255,7 +256,8 @@ void getAncestor_noBlockAtSlot() {
final StorageSystem storageSystem = initStorageSystem();
final SignedBlockAndState head = storageSystem.chainUpdater().advanceChain(5);
final ForkChoiceStrategy protoArrayStrategy = getProtoArray(storageSystem);
assertThat(protoArrayStrategy.getAncestor(head.getRoot(), ONE)).contains(head.getParentRoot());
assertThat(protoArrayStrategy.getAncestor(head.getRoot(), ONE))
.contains(new ChildNode(head.getParentRoot(), head.getSlot(), false));
}

@Test
Expand Down

0 comments on commit 52bb222

Please sign in to comment.