@Test void onBlock_shouldNotProcessAttestationsForBlocksThatDoNotYetExist() { final ChainBuilder forkChain = chainBuilder.fork(); final SignedBlockAndState forkBlock = forkChain.generateBlockAtSlot( UInt64.valueOf(2), BlockOptions.create() .setEth1Data(new Eth1Data(Bytes32.ZERO, UInt64.valueOf(6), Bytes32.ZERO))); final List<SignedBlockAndState> betterChain = chainBuilder.generateBlocksUpToSlot(3); betterChain.forEach(blockAndState -> importBlock(chainBuilder, blockAndState)); final BlockOptions options = BlockOptions.create(); final Attestation attestation = chainBuilder .streamValidAttestationsWithTargetBlock(forkBlock) .findFirst() .orElseThrow( () -> new IllegalStateException( "Failed to create attestation for block " + forkBlock.getRoot() + " genesis root: " + genesis.getRoot() + " chain head: " + chainBuilder.getLatestBlockAndState().getRoot() + " fork block: " + forkBlock.getRoot() + " validators: " + chainBuilder.getValidatorKeys().stream() .map(BLSKeyPair::getPublicKey) .map(BLSPublicKey::toString) .collect(Collectors.joining(", ")))); options.addAttestation(attestation); final SignedBlockAndState blockWithAttestations = chainBuilder.generateBlockAtSlot(UInt64.valueOf(4), options); importBlock(chainBuilder, blockWithAttestations); forkChoice.processHead(blockWithAttestations.getSlot(), false); assertThat(recentChainData.getBestBlockRoot()).contains(blockWithAttestations.getRoot()); importBlock(forkChain, forkBlock); final UInt64 updatedAttestationSlot = applyAttestationFromValidator(UInt64.ZERO, blockWithAttestations); assertDoesNotThrow(() -> forkChoice.processHead(updatedAttestationSlot, false)); }
public void processHead() { processHead(Optional.empty(), false); }
ForkChoice { public void processHead() { processHead(Optional.empty(), false); } }
ForkChoice { public void processHead() { processHead(Optional.empty(), false); } ForkChoice(
      final ForkChoiceExecutor forkChoiceExecutor,
      final RecentChainData recentChainData,
      final StateTransition stateTransition); }
ForkChoice { public void processHead() { processHead(Optional.empty(), false); } ForkChoice(
      final ForkChoiceExecutor forkChoiceExecutor,
      final RecentChainData recentChainData,
      final StateTransition stateTransition); void processHead(); void processHead(UInt64 nodeSlot, boolean syncing); SafeFuture<BlockImportResult> onBlock(
      final SignedBeaconBlock block, Optional<BeaconState> preState); SafeFuture<AttestationProcessingResult> onAttestation(
      final ValidateableAttestation attestation); void save(); void applyIndexedAttestations(final List<ValidateableAttestation> attestations); }
ForkChoice { public void processHead() { processHead(Optional.empty(), false); } ForkChoice(
      final ForkChoiceExecutor forkChoiceExecutor,
      final RecentChainData recentChainData,
      final StateTransition stateTransition); void processHead(); void processHead(UInt64 nodeSlot, boolean syncing); SafeFuture<BlockImportResult> onBlock(
      final SignedBeaconBlock block, Optional<BeaconState> preState); SafeFuture<AttestationProcessingResult> onAttestation(
      final ValidateableAttestation attestation); void save(); void applyIndexedAttestations(final List<ValidateableAttestation> attestations);  }