Search in sources :

Example 1 with StoreConfig

use of tech.pegasys.teku.storage.store.StoreConfig in project teku by ConsenSys.

the class BeaconChainController method initialize.

protected SafeFuture<?> initialize() {
    final StoreConfig storeConfig = beaconConfig.storeConfig();
    coalescingChainHeadChannel = new CoalescingChainHeadChannel(eventChannels.getPublisher(ChainHeadChannel.class), EVENT_LOG);
    StorageQueryChannel storageQueryChannel = eventChannels.getPublisher(StorageQueryChannel.class, beaconAsyncRunner);
    StorageUpdateChannel storageUpdateChannel = eventChannels.getPublisher(StorageUpdateChannel.class, beaconAsyncRunner);
    final VoteUpdateChannel voteUpdateChannel = eventChannels.getPublisher(VoteUpdateChannel.class);
    return initWeakSubjectivity(storageQueryChannel, storageUpdateChannel).thenCompose(__ -> StorageBackedRecentChainData.create(metricsSystem, storeConfig, beaconAsyncRunner, storageQueryChannel, storageUpdateChannel, voteUpdateChannel, eventChannels.getPublisher(FinalizedCheckpointChannel.class, beaconAsyncRunner), coalescingChainHeadChannel, spec)).thenCompose(client -> {
        // Setup chain storage
        this.recentChainData = client;
        if (recentChainData.isPreGenesis()) {
            setupInitialState(client);
        } else if (beaconConfig.eth2NetworkConfig().isUsingCustomInitialState()) {
            STATUS_LOG.warnInitialStateIgnored();
        }
        return SafeFuture.completedFuture(client);
    }).thenAccept(client -> {
        // Init other services
        this.initAll();
        eventChannels.subscribe(TimeTickChannel.class, this);
        recentChainData.subscribeStoreInitialized(this::onStoreInitialized);
        recentChainData.subscribeBestBlockInitialized(this::startServices);
    });
}
Also used : SyncCommitteePerformanceTracker(tech.pegasys.teku.validator.coordinator.performance.SyncCommitteePerformanceTracker) SyncCommitteeSubscriptionManager(tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager) Eth2P2PNetwork(tech.pegasys.teku.networking.eth2.Eth2P2PNetwork) SyncCommitteeStateUtils(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeStateUtils) TimeProvider(tech.pegasys.teku.infrastructure.time.TimeProvider) VersionProvider(tech.pegasys.teku.infrastructure.version.VersionProvider) SyncServiceFactory(tech.pegasys.teku.beacon.sync.SyncServiceFactory) OperationPool(tech.pegasys.teku.statetransition.OperationPool) StableSubnetSubscriber(tech.pegasys.teku.networking.eth2.gossip.subnets.StableSubnetSubscriber) AggregateAttestationValidator(tech.pegasys.teku.statetransition.validation.AggregateAttestationValidator) BlockImportChannel(tech.pegasys.teku.statetransition.block.BlockImportChannel) EpochCachePrimer(tech.pegasys.teku.statetransition.EpochCachePrimer) Duration(java.time.Duration) Path(java.nio.file.Path) Service(tech.pegasys.teku.service.serviceutils.Service) SyncService(tech.pegasys.teku.beacon.sync.SyncService) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) OperationsReOrgManager(tech.pegasys.teku.statetransition.OperationsReOrgManager) ValidatorBasedStableSubnetSubscriber(tech.pegasys.teku.networking.eth2.gossip.subnets.ValidatorBasedStableSubnetSubscriber) NoOpPerformanceTracker(tech.pegasys.teku.validator.coordinator.performance.NoOpPerformanceTracker) SyncCommitteeMessageValidator(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeMessageValidator) TerminalPowBlockMonitor(tech.pegasys.teku.statetransition.forkchoice.TerminalPowBlockMonitor) ActiveValidatorTracker(tech.pegasys.teku.validator.coordinator.ActiveValidatorTracker) AttestationValidator(tech.pegasys.teku.statetransition.validation.AttestationValidator) Logger(org.apache.logging.log4j.Logger) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) RecentChainData(tech.pegasys.teku.storage.client.RecentChainData) BlockManager(tech.pegasys.teku.statetransition.block.BlockManager) ForkChoice(tech.pegasys.teku.statetransition.forkchoice.ForkChoice) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) Bytes(org.apache.tuweni.bytes.Bytes) EventChannels(tech.pegasys.teku.infrastructure.events.EventChannels) WeakSubjectivityValidator(tech.pegasys.teku.weaksubjectivity.WeakSubjectivityValidator) FileKeyValueStore(tech.pegasys.teku.storage.store.FileKeyValueStore) SyncCommitteeMessagePool(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeMessagePool) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) SignatureVerificationService(tech.pegasys.teku.statetransition.validation.signatures.SignatureVerificationService) ZERO(tech.pegasys.teku.infrastructure.unsigned.UInt64.ZERO) SignedBeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock) FinalizedCheckpointChannel(tech.pegasys.teku.storage.api.FinalizedCheckpointChannel) ForkChoiceNotifierImpl(tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifierImpl) AttestationManager(tech.pegasys.teku.statetransition.attestation.AttestationManager) DiscoveryConfig(tech.pegasys.teku.networking.p2p.discovery.DiscoveryConfig) Throwables(com.google.common.base.Throwables) InteropStartupUtil(tech.pegasys.teku.spec.datastructures.interop.InteropStartupUtil) StorageQueryChannel(tech.pegasys.teku.storage.api.StorageQueryChannel) ServiceConfig(tech.pegasys.teku.service.serviceutils.ServiceConfig) PerformanceTracker(tech.pegasys.teku.validator.coordinator.performance.PerformanceTracker) BlockImportNotifications(tech.pegasys.teku.statetransition.block.BlockImportNotifications) CoalescingChainHeadChannel(tech.pegasys.teku.beacon.sync.events.CoalescingChainHeadChannel) STATUS_LOG(tech.pegasys.teku.infrastructure.logging.StatusLogger.STATUS_LOG) SpecMilestone(tech.pegasys.teku.spec.SpecMilestone) CombinedChainDataClient(tech.pegasys.teku.storage.client.CombinedChainDataClient) StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) StorageBackedRecentChainData(tech.pegasys.teku.storage.client.StorageBackedRecentChainData) InvalidConfigurationException(tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException) ValidatorPerformanceTrackingMode(tech.pegasys.teku.validator.api.ValidatorPerformanceTrackingMode) Random(java.util.Random) AggregatingAttestationPool(tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool) Eth1VotingPeriod(tech.pegasys.teku.validator.coordinator.Eth1VotingPeriod) P2PConfig(tech.pegasys.teku.networking.eth2.P2PConfig) AttesterSlashing(tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing) ProposerSlashingValidator(tech.pegasys.teku.statetransition.validation.ProposerSlashingValidator) BeaconBlockBodySchema(tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema) Eth2P2PNetworkBuilder(tech.pegasys.teku.networking.eth2.Eth2P2PNetworkBuilder) ChainDataProvider(tech.pegasys.teku.api.ChainDataProvider) ActiveValidatorChannel(tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel) Eth1DataCache(tech.pegasys.teku.validator.coordinator.Eth1DataCache) DefaultPerformanceTracker(tech.pegasys.teku.validator.coordinator.performance.DefaultPerformanceTracker) BlockFactory(tech.pegasys.teku.validator.coordinator.BlockFactory) ValidatorApiHandler(tech.pegasys.teku.validator.coordinator.ValidatorApiHandler) DepositProvider(tech.pegasys.teku.validator.coordinator.DepositProvider) TimeTickChannel(tech.pegasys.teku.services.timer.TimeTickChannel) ExecutionEngineChannel(tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel) OperationAcceptedFilter(tech.pegasys.teku.statetransition.OperationAcceptedFilter) BlockValidator(tech.pegasys.teku.statetransition.validation.BlockValidator) FutureItems(tech.pegasys.teku.statetransition.util.FutureItems) AttesterSlashingValidator(tech.pegasys.teku.statetransition.validation.AttesterSlashingValidator) BlockOperationSelectorFactory(tech.pegasys.teku.validator.coordinator.BlockOperationSelectorFactory) SyncCommitteeContributionPool(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool) AsyncRunnerFactory(tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory) ForkChoiceNotifier(tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifier) Optional(java.util.Optional) PortAvailability(tech.pegasys.teku.infrastructure.io.PortAvailability) VoteUpdateChannel(tech.pegasys.teku.storage.api.VoteUpdateChannel) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) ActiveValidatorCache(tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorCache) SignedContributionAndProofValidator(tech.pegasys.teku.statetransition.synccommittee.SignedContributionAndProofValidator) BlockGossipChannel(tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel) ChainHeadChannel(tech.pegasys.teku.storage.api.ChainHeadChannel) ReexecutingExecutionPayloadBlockManager(tech.pegasys.teku.statetransition.block.ReexecutingExecutionPayloadBlockManager) ForkChoiceTrigger(tech.pegasys.teku.statetransition.forkchoice.ForkChoiceTrigger) AttestationTopicSubscriber(tech.pegasys.teku.networking.eth2.gossip.subnets.AttestationTopicSubscriber) BindException(java.net.BindException) DutyMetrics(tech.pegasys.teku.validator.coordinator.DutyMetrics) Function(java.util.function.Function) NoOpEth2P2PNetwork(tech.pegasys.teku.networking.eth2.mock.NoOpEth2P2PNetwork) ValidatorPerformanceMetrics(tech.pegasys.teku.validator.coordinator.performance.ValidatorPerformanceMetrics) KeyValueStore(tech.pegasys.teku.storage.store.KeyValueStore) ProposerSlashing(tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing) PendingPool(tech.pegasys.teku.statetransition.util.PendingPool) Bytes20(tech.pegasys.teku.infrastructure.bytes.Bytes20) BlockImporter(tech.pegasys.teku.statetransition.block.BlockImporter) Spec(tech.pegasys.teku.spec.Spec) AggregatingSignatureVerificationService(tech.pegasys.teku.statetransition.validation.signatures.AggregatingSignatureVerificationService) SlotEventsChannel(tech.pegasys.teku.ethereum.events.SlotEventsChannel) VoluntaryExitValidator(tech.pegasys.teku.statetransition.validation.VoluntaryExitValidator) EVENT_LOG(tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG) StorageUpdateChannel(tech.pegasys.teku.storage.api.StorageUpdateChannel) AllSubnetsSubscriber(tech.pegasys.teku.networking.eth2.gossip.subnets.AllSubnetsSubscriber) BeaconRestApi(tech.pegasys.teku.beaconrestapi.BeaconRestApi) AnchorPoint(tech.pegasys.teku.spec.datastructures.state.AnchorPoint) ValidateableAttestation(tech.pegasys.teku.spec.datastructures.attestation.ValidateableAttestation) GenesisHandler(tech.pegasys.teku.statetransition.genesis.GenesisHandler) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) DataProvider(tech.pegasys.teku.api.DataProvider) AllSyncCommitteeSubscriptions(tech.pegasys.teku.networking.eth2.gossip.subnets.AllSyncCommitteeSubscriptions) Eth1EventsChannel(tech.pegasys.teku.pow.api.Eth1EventsChannel) InteropConfig(tech.pegasys.teku.validator.api.InteropConfig) AsyncRunnerEventThread(tech.pegasys.teku.infrastructure.async.eventthread.AsyncRunnerEventThread) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) MergeTransitionBlockValidator(tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator) StorageQueryChannel(tech.pegasys.teku.storage.api.StorageQueryChannel) CoalescingChainHeadChannel(tech.pegasys.teku.beacon.sync.events.CoalescingChainHeadChannel) StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) VoteUpdateChannel(tech.pegasys.teku.storage.api.VoteUpdateChannel) StorageUpdateChannel(tech.pegasys.teku.storage.api.StorageUpdateChannel)

Example 2 with StoreConfig

use of tech.pegasys.teku.storage.store.StoreConfig in project teku by ConsenSys.

the class AbstractKvStoreDatabaseWithHotStatesTest method shouldPersistHotStates_everyThirdEpoch.

@Test
public void shouldPersistHotStates_everyThirdEpoch() {
    final int storageFrequency = 3;
    StoreConfig storeConfig = StoreConfig.builder().hotStatePersistenceFrequencyInEpochs(storageFrequency).build();
    createStorage(StateStorageMode.ARCHIVE, storeConfig, false);
    initGenesis();
    final UInt64 latestEpoch = UInt64.valueOf(3 * storageFrequency);
    final UInt64 targetSlot = spec.computeStartSlotAtEpoch(latestEpoch);
    chainBuilder.generateBlocksUpToSlot(targetSlot);
    // Add blocks
    addBlocks(chainBuilder.streamBlocksAndStates().collect(toList()));
    // We should only be able to pull states at epoch boundaries
    final Set<UInt64> epochBoundarySlots = getEpochBoundarySlots(1, latestEpoch.intValue());
    for (int i = 0; i <= targetSlot.intValue(); i++) {
        final SignedBlockAndState blockAndState = chainBuilder.getBlockAndStateAtSlot(i);
        final Optional<BeaconState> actual = database.getHotState(blockAndState.getRoot());
        final UInt64 currentSlot = UInt64.valueOf(i);
        final UInt64 currentEpoch = spec.computeEpochAtSlot(currentSlot);
        final boolean shouldPersistThisEpoch = currentEpoch.mod(storageFrequency).equals(UInt64.ZERO);
        if (epochBoundarySlots.contains(currentSlot) && shouldPersistThisEpoch) {
            assertThat(actual).contains(blockAndState.getState());
        } else {
            assertThat(actual).isEmpty();
        }
    }
}
Also used : StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) Test(org.junit.jupiter.api.Test)

Example 3 with StoreConfig

use of tech.pegasys.teku.storage.store.StoreConfig in project teku by ConsenSys.

the class StoreOptionsTest method hotStatePersistenceFrequency_shouldSetDefaultValue.

@Test
public void hotStatePersistenceFrequency_shouldSetDefaultValue() {
    final StoreConfig globalConfiguration = getTekuConfigurationFromArguments().beaconChain().storeConfig();
    assertThat(globalConfiguration.getHotStatePersistenceFrequencyInEpochs()).isEqualTo(2);
}
Also used : StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) Test(org.junit.jupiter.api.Test) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 4 with StoreConfig

use of tech.pegasys.teku.storage.store.StoreConfig in project teku by ConsenSys.

the class StoreOptionsTest method hotStatePersistenceFrequency_shouldRespectCLIArg.

@Test
public void hotStatePersistenceFrequency_shouldRespectCLIArg() {
    final String[] args = { "--Xhot-state-persistence-frequency", "99" };
    TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments(args);
    final StoreConfig globalConfiguration = tekuConfiguration.beaconChain().storeConfig();
    assertThat(globalConfiguration.getHotStatePersistenceFrequencyInEpochs()).isEqualTo(99);
    assertThat(createConfigBuilder().store(b -> b.hotStatePersistenceFrequencyInEpochs(99)).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
Also used : TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) Test(org.junit.jupiter.api.Test) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 5 with StoreConfig

use of tech.pegasys.teku.storage.store.StoreConfig in project teku by ConsenSys.

the class AbstractKvStoreDatabaseWithHotStatesTest method shouldClearStaleHotStates.

@Test
public void shouldClearStaleHotStates() {
    final int storageFrequency = 1;
    StoreConfig storeConfig = StoreConfig.builder().hotStatePersistenceFrequencyInEpochs(storageFrequency).build();
    createStorage(StateStorageMode.ARCHIVE, storeConfig, false);
    initGenesis();
    final UInt64 latestEpoch = UInt64.valueOf(3);
    final UInt64 targetSlot = spec.computeStartSlotAtEpoch(latestEpoch);
    chainBuilder.generateBlocksUpToSlot(targetSlot);
    // Add blocks
    addBlocks(chainBuilder.streamBlocksAndStates().collect(toList()));
    justifyAndFinalizeEpoch(latestEpoch, chainBuilder.getLatestBlockAndState());
    // Hot states should be cleared out
    for (int i = 0; i <= targetSlot.intValue(); i++) {
        final SignedBlockAndState blockAndState = chainBuilder.getBlockAndStateAtSlot(i);
        final Optional<BeaconState> actual = database.getHotState(blockAndState.getRoot());
        assertThat(actual).isEmpty();
    }
}
Also used : StoreConfig(tech.pegasys.teku.storage.store.StoreConfig) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) Test(org.junit.jupiter.api.Test)

Aggregations

StoreConfig (tech.pegasys.teku.storage.store.StoreConfig)9 Test (org.junit.jupiter.api.Test)8 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)5 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)5 Optional (java.util.Optional)3 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)3 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)3 AbstractBeaconNodeCommandTest (tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)2 StubMetricsSystem (tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem)2 UpdatableStore (tech.pegasys.teku.storage.store.UpdatableStore)2 Throwables (com.google.common.base.Throwables)1 BindException (java.net.BindException)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Comparator (java.util.Comparator)1 Random (java.util.Random)1 Function (java.util.function.Function)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Bytes (org.apache.tuweni.bytes.Bytes)1