Search in sources :

Example 1 with StubMetricsSystem

use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.

the class DepositProviderTest method setup.

void setup(final int maxDeposits) {
    when(state.getSlot()).thenReturn(UInt64.valueOf(1234));
    SpecConfig specConfig = SpecConfigLoader.loadConfig("minimal", b -> b.maxDeposits(maxDeposits));
    spec = TestSpecFactory.createPhase0(specConfig);
    depositUtil = new DepositUtil(spec);
    dataStructureUtil = new DataStructureUtil(spec);
    depositProvider = new DepositProvider(new StubMetricsSystem(), recentChainData, eth1DataCache, spec);
    depositMerkleTree = new OptimizedMerkleTree(spec.getGenesisSpecConfig().getDepositContractTreeDepth());
    mockStateEth1DataVotes();
    createDepositEvents(40);
    randomEth1Data = dataStructureUtil.randomEth1Data();
}
Also used : DepositUtil(tech.pegasys.teku.spec.datastructures.util.DepositUtil) OptimizedMerkleTree(tech.pegasys.teku.spec.datastructures.util.OptimizedMerkleTree) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

Example 2 with StubMetricsSystem

use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.

the class AbstractStoreTest method createGenesisStore.

protected UpdatableStore createGenesisStore(final StoreConfig pruningOptions) {
    final SignedBlockAndState genesis = chainBuilder.generateGenesis();
    final Checkpoint genesisCheckpoint = chainBuilder.getCurrentCheckpointForEpoch(0);
    return StoreBuilder.create().asyncRunner(SYNC_RUNNER).metricsSystem(new StubMetricsSystem()).specProvider(spec).blockProvider(blockProviderFromChainBuilder()).stateProvider(StateAndBlockSummaryProvider.NOOP).anchor(Optional.empty()).genesisTime(genesis.getState().getGenesis_time()).time(genesis.getState().getGenesis_time()).latestFinalized(AnchorPoint.create(spec, genesisCheckpoint, genesis)).justifiedCheckpoint(genesisCheckpoint).bestJustifiedCheckpoint(genesisCheckpoint).blockInformation(Map.of(genesis.getRoot(), new StoredBlockMetadata(genesis.getSlot(), genesis.getRoot(), genesis.getParentRoot(), genesis.getStateRoot(), genesis.getExecutionBlockHash(), Optional.of(new CheckpointEpochs(UInt64.ZERO, UInt64.ZERO))))).storeConfig(pruningOptions).votes(emptyMap()).build();
}
Also used : Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) CheckpointEpochs(tech.pegasys.teku.spec.datastructures.blocks.CheckpointEpochs) StoredBlockMetadata(tech.pegasys.teku.ethereum.forkchoice.StoredBlockMetadata) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)

Example 3 with StubMetricsSystem

use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.

the class StoreTest method create_timeLessThanGenesisTime.

@Test
public void create_timeLessThanGenesisTime() {
    final UInt64 genesisTime = UInt64.valueOf(100);
    final SignedBlockAndState genesis = chainBuilder.generateGenesis(genesisTime, false);
    final Checkpoint genesisCheckpoint = chainBuilder.getCurrentCheckpointForEpoch(0);
    assertThatThrownBy(() -> Store.create(SYNC_RUNNER, new StubMetricsSystem(), spec, blockProviderFromChainBuilder(), StateAndBlockSummaryProvider.NOOP, Optional.empty(), genesisTime.minus(1), genesisTime, AnchorPoint.create(spec, genesisCheckpoint, genesis), Optional.empty(), genesisCheckpoint, genesisCheckpoint, Collections.emptyMap(), Collections.emptyMap(), StoreConfig.createDefault())).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Time must be greater than or equal to genesisTime");
}
Also used : Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) Test(org.junit.jupiter.api.Test)

Example 4 with StubMetricsSystem

use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.

the class AggregatingSignatureVerificationServiceTest method testRealServiceWithThreads.

@Test
public void testRealServiceWithThreads() throws Exception {
    final MetricsSystem metrics = new StubMetricsSystem();
    final AsyncRunnerFactory realRunnerFactory = AsyncRunnerFactory.createDefault(new MetricTrackingExecutorFactory(metrics));
    service = new AggregatingSignatureVerificationService(metrics, realRunnerFactory, realRunnerFactory.create("completion", 1), 1, queueCapacity, batchSize, minBatchSizeToSplit, strictThreadLimitEnabled);
    startService();
    final Random random = new Random(1);
    for (int i = 0; i < 3; i++) {
        final List<SafeFuture<Boolean>> validFutures = new ArrayList<>();
        final List<SafeFuture<Boolean>> invalidFutures = new ArrayList<>();
        for (int j = 0; j < queueCapacity - i; j++) {
            if (random.nextFloat() < .5) {
                validFutures.add(executeValidVerify(j, j));
            } else {
                invalidFutures.add(executeInvalidVerify(j, j));
            }
        }
        final List<SafeFuture<Boolean>> allFutures = new ArrayList<>();
        allFutures.addAll(validFutures);
        allFutures.addAll(invalidFutures);
        Waiter.waitFor(SafeFuture.allOf(allFutures.toArray(SafeFuture<?>[]::new)), Duration.ofSeconds(5));
        validFutures.forEach(f -> assertThat(f).isCompletedWithValue(true));
        invalidFutures.forEach(f -> assertThat(f).isCompletedWithValue(false));
    }
}
Also used : StubAsyncRunnerFactory(tech.pegasys.teku.infrastructure.async.StubAsyncRunnerFactory) AsyncRunnerFactory(tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory) Random(java.util.Random) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) MetricTrackingExecutorFactory(tech.pegasys.teku.infrastructure.async.MetricTrackingExecutorFactory) ArrayList(java.util.ArrayList) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) Test(org.junit.jupiter.api.Test)

Example 5 with StubMetricsSystem

use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.

the class StorageBackedRecentChainDataTest method storageBackedClient_storeInitializeViaGetStoreRequestAfterIOException.

@Test
public void storageBackedClient_storeInitializeViaGetStoreRequestAfterIOException() {
    SafeFuture<Optional<StoreBuilder>> storeRequestFuture = new SafeFuture<>();
    when(storageQueryChannel.onStoreRequest()).thenReturn(SafeFuture.failedFuture(new IOException())).thenReturn(storeRequestFuture);
    final SafeFuture<RecentChainData> client = StorageBackedRecentChainData.create(new StubMetricsSystem(), StoreConfig.createDefault(), asyncRunner, storageQueryChannel, storageUpdateChannel, voteUpdateChannel, finalizedCheckpointChannel, chainHeadChannel, spec);
    // We should have posted a request to get the store from storage
    verify(storageQueryChannel).onStoreRequest();
    assertThat(client).isCompletedExceptionally();
}
Also used : Optional(java.util.Optional) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Aggregations

StubMetricsSystem (tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem)16 Test (org.junit.jupiter.api.Test)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)5 Optional (java.util.Optional)4 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)2 Checkpoint (tech.pegasys.teku.spec.datastructures.state.Checkpoint)2 DataStructureUtil (tech.pegasys.teku.spec.util.DataStructureUtil)2 StoreBuilder (tech.pegasys.teku.storage.store.StoreBuilder)2 StoreConfig (tech.pegasys.teku.storage.store.StoreConfig)2 UpdatableStore (tech.pegasys.teku.storage.store.UpdatableStore)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 TimeoutException (java.util.concurrent.TimeoutException)1 MetricsSystem (org.hyperledger.besu.plugin.services.MetricsSystem)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)1 StoredBlockMetadata (tech.pegasys.teku.ethereum.forkchoice.StoredBlockMetadata)1 AsyncRunnerFactory (tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory)1