@Test public void getAncestorsOnFork() { final ChainBuilder chainBuilder = ChainBuilder.create(BLSKeyGenerator.generateKeyPairs(16)); final SignedBlockAndState genesis = chainBuilder.generateGenesis(); preGenesisStorageClient.initializeFromGenesis(genesis.getState()).join(); chainBuilder.generateBlockAtSlot(1); final List<BlockOptions> blockOptions = chainBuilder .streamValidAttestationsForBlockAtSlot(ONE) .map(attestation -> BlockOptions.create().addAttestation(attestation)) .limit(2) .collect(toList()); final ChainBuilder forkBuilder = chainBuilder.fork(); final SignedBlockAndState firstBlockAndState = chainBuilder.generateBlockAtSlot(UInt64.valueOf(2), blockOptions.get(0)); final SignedBlockAndState latestBlockAndState = chainBuilder.generateBlockAtSlot(UInt64.valueOf(3)); final SignedBlockAndState forkFirstBlockAndState = forkBuilder.generateBlockAtSlot(UInt64.valueOf(2), blockOptions.get(1)); final SignedBlockAndState latestForkBlockAndState = forkBuilder.generateBlockAtSlot(UInt64.valueOf(3), blockOptions.get(1)); importBlocksAndStates(preGenesisStorageClient, chainBuilder, forkBuilder); assertThat( preGenesisStorageClient.getAncestorsOnFork( UInt64.valueOf(1), latestBlockAndState.getRoot())) .containsOnly( Map.entry(UInt64.valueOf(2), firstBlockAndState.getRoot()), Map.entry(UInt64.valueOf(3), latestBlockAndState.getRoot())); assertThat( preGenesisStorageClient.getAncestorsOnFork( UInt64.valueOf(1), latestForkBlockAndState.getRoot())) .containsOnly( Map.entry(UInt64.valueOf(2), forkFirstBlockAndState.getRoot()), Map.entry(UInt64.valueOf(3), latestForkBlockAndState.getRoot())); }
public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root) { return ForkChoiceUtil.getAncestorsOnFork(forkChoiceStrategy.orElseThrow(), root, startSlot); }
RecentChainData implements StoreUpdateHandler { public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root) { return ForkChoiceUtil.getAncestorsOnFork(forkChoiceStrategy.orElseThrow(), root, startSlot); } }
RecentChainData implements StoreUpdateHandler { public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root) { return ForkChoiceUtil.getAncestorsOnFork(forkChoiceStrategy.orElseThrow(), root, startSlot); } RecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateProvider,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); }
RecentChainData implements StoreUpdateHandler { public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root) { return ForkChoiceUtil.getAncestorsOnFork(forkChoiceStrategy.orElseThrow(), root, startSlot); } RecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateProvider,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); void subscribeStoreInitialized(Runnable runnable); void subscribeBestBlockInitialized(Runnable runnable); SafeFuture<Void> initializeFromGenesis(final BeaconState genesisState); UInt64 getGenesisTime(); boolean isPreGenesis(); boolean isPreForkChoice(); UpdatableStore getStore(); NavigableMap<UInt64, Bytes32> getAncestorRootsOnHeadChain(
      final UInt64 startSlot, final UInt64 step, final UInt64 count); NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root); Optional<ForkChoiceStrategy> getForkChoiceStrategy(); StoreTransaction startStoreTransaction(); void updateHead(Bytes32 root, UInt64 currentSlot); void updateHead(Bytes32 root, UInt64 currentSlot, boolean syncing); Optional<UInt64> getCurrentSlot(); Optional<ForkInfo> getHeadForkInfo(); Optional<Fork> getNextFork(); Optional<ForkInfo> getForkInfoAtCurrentTime(); Optional<Bytes32> getBestBlockRoot(); Optional<BeaconBlockAndState> getHeadBlockAndState(); Optional<SignedBeaconBlock> getHeadBlock(); Optional<BeaconState> getBestState(); UInt64 getHeadSlot(); boolean containsBlock(final Bytes32 root); SafeFuture<Optional<BeaconBlock>> retrieveBlockByRoot(final Bytes32 root); SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlockByRoot(final Bytes32 root); SafeFuture<Optional<BeaconState>> retrieveBlockState(final Bytes32 blockRoot); SafeFuture<Optional<BeaconState>> retrieveStateInEffectAtSlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot, final Bytes32 headBlockRoot); UInt64 getFinalizedEpoch(); Optional<Checkpoint> getFinalizedCheckpoint(); Optional<Checkpoint> getJustifiedCheckpoint(); @Override void onNewFinalizedCheckpoint(Checkpoint finalizedCheckpoint); SafeFuture<Optional<BeaconState>> retrieveCheckpointState(final Checkpoint checkpoint); }
RecentChainData implements StoreUpdateHandler { public NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root) { return ForkChoiceUtil.getAncestorsOnFork(forkChoiceStrategy.orElseThrow(), root, startSlot); } RecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateProvider,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); void subscribeStoreInitialized(Runnable runnable); void subscribeBestBlockInitialized(Runnable runnable); SafeFuture<Void> initializeFromGenesis(final BeaconState genesisState); UInt64 getGenesisTime(); boolean isPreGenesis(); boolean isPreForkChoice(); UpdatableStore getStore(); NavigableMap<UInt64, Bytes32> getAncestorRootsOnHeadChain(
      final UInt64 startSlot, final UInt64 step, final UInt64 count); NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root); Optional<ForkChoiceStrategy> getForkChoiceStrategy(); StoreTransaction startStoreTransaction(); void updateHead(Bytes32 root, UInt64 currentSlot); void updateHead(Bytes32 root, UInt64 currentSlot, boolean syncing); Optional<UInt64> getCurrentSlot(); Optional<ForkInfo> getHeadForkInfo(); Optional<Fork> getNextFork(); Optional<ForkInfo> getForkInfoAtCurrentTime(); Optional<Bytes32> getBestBlockRoot(); Optional<BeaconBlockAndState> getHeadBlockAndState(); Optional<SignedBeaconBlock> getHeadBlock(); Optional<BeaconState> getBestState(); UInt64 getHeadSlot(); boolean containsBlock(final Bytes32 root); SafeFuture<Optional<BeaconBlock>> retrieveBlockByRoot(final Bytes32 root); SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlockByRoot(final Bytes32 root); SafeFuture<Optional<BeaconState>> retrieveBlockState(final Bytes32 blockRoot); SafeFuture<Optional<BeaconState>> retrieveStateInEffectAtSlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot, final Bytes32 headBlockRoot); UInt64 getFinalizedEpoch(); Optional<Checkpoint> getFinalizedCheckpoint(); Optional<Checkpoint> getJustifiedCheckpoint(); @Override void onNewFinalizedCheckpoint(Checkpoint finalizedCheckpoint); SafeFuture<Optional<BeaconState>> retrieveCheckpointState(final Checkpoint checkpoint);  }