@Test public void storageBackedClient_storeInitializeViaNewGenesisState() throws ExecutionException, InterruptedException { SafeFuture<Optional<StoreBuilder>> storeRequestFuture = new SafeFuture<>(); when(storageQueryChannel.onStoreRequest()).thenReturn(storeRequestFuture); final EventBus eventBus = new EventBus(); final StoreConfig storeConfig = StoreConfig.builder().hotStatePersistenceFrequencyInEpochs(5).build(); final SafeFuture<RecentChainData> client = StorageBackedRecentChainData.create( new StubMetricsSystem(), storeConfig, asyncRunner, storageQueryChannel, storageUpdateChannel, new StubProtoArrayStorageChannel(), finalizedCheckpointChannel, chainHeadChannel, eventBus); verify(storageQueryChannel).onStoreRequest(); assertThat(client).isNotDone(); storeRequestFuture.complete(Optional.empty()); assertThat(client).isCompleted(); assertStoreNotInitialized(client.get()); assertThat(client.get().getStore()).isNull(); final UpdatableStore genesisStore = StoreBuilder.forkChoiceStoreBuilder( SYNC_RUNNER, new StubMetricsSystem(), BlockProvider.NOOP, StateAndBlockProvider.NOOP, AnchorPoint.fromGenesisState(INITIAL_STATE)) .storeConfig(storeConfig) .build() .join(); final SafeFuture<Void> initialized = client.get().initializeFromGenesis(INITIAL_STATE); assertThat(initialized).isCompleted(); assertStoreInitialized(client.get()); assertStoreIsSet(client.get()); StoreAssertions.assertStoresMatch(client.get().getStore(), genesisStore); }
public static SafeFuture<RecentChainData> create( final MetricsSystem metricsSystem, final StoreConfig storeConfig, final AsyncRunner asyncRunner, final StorageQueryChannel storageQueryChannel, final StorageUpdateChannel storageUpdateChannel, final ProtoArrayStorageChannel protoArrayStorageChannel, final FinalizedCheckpointChannel finalizedCheckpointChannel, final ChainHeadChannel chainHeadChannel, final EventBus eventBus) { StorageBackedRecentChainData client = new StorageBackedRecentChainData( asyncRunner, metricsSystem, storeConfig, storageQueryChannel, storageUpdateChannel, protoArrayStorageChannel, finalizedCheckpointChannel, chainHeadChannel, eventBus); return client.initializeFromStorageWithRetry(asyncRunner); }
StorageBackedRecentChainData extends RecentChainData { public static SafeFuture<RecentChainData> create( final MetricsSystem metricsSystem, final StoreConfig storeConfig, final AsyncRunner asyncRunner, final StorageQueryChannel storageQueryChannel, final StorageUpdateChannel storageUpdateChannel, final ProtoArrayStorageChannel protoArrayStorageChannel, final FinalizedCheckpointChannel finalizedCheckpointChannel, final ChainHeadChannel chainHeadChannel, final EventBus eventBus) { StorageBackedRecentChainData client = new StorageBackedRecentChainData( asyncRunner, metricsSystem, storeConfig, storageQueryChannel, storageUpdateChannel, protoArrayStorageChannel, finalizedCheckpointChannel, chainHeadChannel, eventBus); return client.initializeFromStorageWithRetry(asyncRunner); } }
StorageBackedRecentChainData extends RecentChainData { public static SafeFuture<RecentChainData> create( final MetricsSystem metricsSystem, final StoreConfig storeConfig, final AsyncRunner asyncRunner, final StorageQueryChannel storageQueryChannel, final StorageUpdateChannel storageUpdateChannel, final ProtoArrayStorageChannel protoArrayStorageChannel, final FinalizedCheckpointChannel finalizedCheckpointChannel, final ChainHeadChannel chainHeadChannel, final EventBus eventBus) { StorageBackedRecentChainData client = new StorageBackedRecentChainData( asyncRunner, metricsSystem, storeConfig, storageQueryChannel, storageUpdateChannel, protoArrayStorageChannel, finalizedCheckpointChannel, chainHeadChannel, eventBus); return client.initializeFromStorageWithRetry(asyncRunner); } StorageBackedRecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); }
StorageBackedRecentChainData extends RecentChainData { public static SafeFuture<RecentChainData> create( final MetricsSystem metricsSystem, final StoreConfig storeConfig, final AsyncRunner asyncRunner, final StorageQueryChannel storageQueryChannel, final StorageUpdateChannel storageUpdateChannel, final ProtoArrayStorageChannel protoArrayStorageChannel, final FinalizedCheckpointChannel finalizedCheckpointChannel, final ChainHeadChannel chainHeadChannel, final EventBus eventBus) { StorageBackedRecentChainData client = new StorageBackedRecentChainData( asyncRunner, metricsSystem, storeConfig, storageQueryChannel, storageUpdateChannel, protoArrayStorageChannel, finalizedCheckpointChannel, chainHeadChannel, eventBus); return client.initializeFromStorageWithRetry(asyncRunner); } StorageBackedRecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); static SafeFuture<RecentChainData> create(
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final AsyncRunner asyncRunner,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); @VisibleForTesting static RecentChainData createImmediately(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); }
StorageBackedRecentChainData extends RecentChainData { public static SafeFuture<RecentChainData> create( final MetricsSystem metricsSystem, final StoreConfig storeConfig, final AsyncRunner asyncRunner, final StorageQueryChannel storageQueryChannel, final StorageUpdateChannel storageUpdateChannel, final ProtoArrayStorageChannel protoArrayStorageChannel, final FinalizedCheckpointChannel finalizedCheckpointChannel, final ChainHeadChannel chainHeadChannel, final EventBus eventBus) { StorageBackedRecentChainData client = new StorageBackedRecentChainData( asyncRunner, metricsSystem, storeConfig, storageQueryChannel, storageUpdateChannel, protoArrayStorageChannel, finalizedCheckpointChannel, chainHeadChannel, eventBus); return client.initializeFromStorageWithRetry(asyncRunner); } StorageBackedRecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); static SafeFuture<RecentChainData> create(
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final AsyncRunner asyncRunner,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); @VisibleForTesting static RecentChainData createImmediately(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final StorageQueryChannel storageQueryChannel,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus);  }