use of tech.pegasys.teku.storage.api.schema.ReplayDepositsResult in project teku by ConsenSys.
the class DepositStorageTest method shouldFailIfStoredDepositsEventIsMissingDeposits.
@ParameterizedTest(name = "{0}")
@ArgumentsSource(StorageSystemArgumentsProvider.class)
public void shouldFailIfStoredDepositsEventIsMissingDeposits(final String storageType, final StorageSystemArgumentsProvider.StorageSystemSupplier storageSystemSupplier) {
setup(storageSystemSupplier);
final DepositsFromBlockEvent invalidEvent = new UnsafeDepositsFromBlockEvent(block_99.getBlockNumber(), block_99.getBlockHash(), block_99.getBlockTimestamp(), List.of(dataStructureUtil.randomDepositEvent(UInt64.valueOf(0)), // Deposit at index 1 is skipped
dataStructureUtil.randomDepositEvent(UInt64.valueOf(2))));
database.addDepositsFromBlockEvent(invalidEvent);
SafeFuture<ReplayDepositsResult> future = depositStorage.replayDepositEvents();
assertThat(future).isCompletedExceptionally();
assertThatThrownBy(future::get).hasCauseInstanceOf(InvalidDepositEventsException.class);
}
use of tech.pegasys.teku.storage.api.schema.ReplayDepositsResult in project teku by ConsenSys.
the class DepositStorageTest method shouldSendGenesisBeforeFirstDeposit.
@ParameterizedTest(name = "{0}")
@ArgumentsSource(StorageSystemArgumentsProvider.class)
public void shouldSendGenesisBeforeFirstDeposit(final String storageType, final StorageSystemArgumentsProvider.StorageSystemSupplier storageSystemSupplier) throws ExecutionException, InterruptedException {
setup(storageSystemSupplier);
final DepositsFromBlockEvent postGenesisDeposits = dataStructureUtil.randomDepositsFromBlockEvent(101L, 0, 21);
database.addMinGenesisTimeBlock(genesis_100);
database.addDepositsFromBlockEvent(postGenesisDeposits);
SafeFuture<ReplayDepositsResult> future = depositStorage.replayDepositEvents();
assertThat(future).isCompleted();
assertThat(eventsChannel.getOrderedList()).containsExactly(genesis_100, postGenesisDeposits);
assertThat(eventsChannel.getGenesis()).isEqualToComparingFieldByField(genesis_100);
assertThat(future.get().getLastProcessedBlockNumber()).isEqualTo(postGenesisDeposits.getBlockNumber().bigIntegerValue());
assertThat(future.get().getLastProcessedDepositIndex()).hasValue(postGenesisDeposits.getLastDepositIndex().bigIntegerValue());
assertThat(future.get().isPastMinGenesisBlock()).isTrue();
}
use of tech.pegasys.teku.storage.api.schema.ReplayDepositsResult in project teku by ConsenSys.
the class DepositStorage method replayDeposits.
private ReplayDepositsResult replayDeposits() {
final DepositSequencer depositSequencer = new DepositSequencer(eth1EventsChannel, database.getMinGenesisTimeBlock());
try (Stream<DepositsFromBlockEvent> eventStream = database.streamDepositsFromBlocks()) {
eventStream.forEach(depositSequencer::depositEvent);
}
ReplayDepositsResult result = depositSequencer.depositsComplete();
lastReplayedBlock = Optional.of(result.getLastProcessedBlockNumber());
return result;
}
Aggregations