Search in sources :

Example 1 with DataProvider

use of tech.pegasys.teku.api.DataProvider in project teku by ConsenSys.

the class BeaconRestApiV1Test method setup.

@BeforeEach
public void setup() {
    final Eth1Address depositContractAddress = new Eth1Address(Bytes.fromHexString("0xdddddddddddddddddddddddddddddddddddddddd"));
    BeaconRestApiConfig beaconRestApiConfig = BeaconRestApiConfig.builder().restApiDocsEnabled(false).eth1DepositContractAddress(depositContractAddress).restApiPort(THE_PORT).build();
    when(app.jettyServer()).thenReturn(server);
    final DataProvider dataProvider = DataProvider.builder().spec(TestSpecFactory.createMinimalPhase0()).recentChainData(storageClient).combinedChainDataClient(combinedChainDataClient).p2pNetwork(null).syncService(syncService).validatorApiChannel(null).blockManager(blockManager).attestationManager(attestationManager).isLivenessTrackingEnabled(false).activeValidatorChannel(activeValidatorChannel).attestationPool(attestationPool).attesterSlashingPool(attesterSlashingPool).proposerSlashingPool(proposerSlashingPool).voluntaryExitPool(voluntaryExitPool).syncCommitteeContributionPool(syncCommitteeContributionPool).build();
    new BeaconRestApi(dataProvider, beaconRestApiConfig, eventChannels, new StubAsyncRunner(), app);
}
Also used : DataProvider(tech.pegasys.teku.api.DataProvider) StubAsyncRunner(tech.pegasys.teku.infrastructure.async.StubAsyncRunner) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with DataProvider

use of tech.pegasys.teku.api.DataProvider in project teku by ConsenSys.

the class BeaconRestApiTest method setup.

@BeforeEach
public void setup() {
    BeaconRestApiConfig beaconRestApiConfig = BeaconRestApiConfig.builder().restApiDocsEnabled(false).restApiPort(THE_PORT).eth1DepositContractAddress(Eth1Address.ZERO).build();
    when(app.jettyServer()).thenReturn(server);
    final DataProvider dataProvider = DataProvider.builder().spec(TestSpecFactory.createMinimalPhase0()).recentChainData(storageClient).combinedChainDataClient(combinedChainDataClient).p2pNetwork(null).syncService(syncService).validatorApiChannel(null).blockManager(blockManager).attestationManager(attestationManager).isLivenessTrackingEnabled(false).activeValidatorChannel(activeValidatorChannel).attestationPool(attestationPool).attesterSlashingPool(attesterSlashingPool).proposerSlashingPool(proposerSlashingPool).voluntaryExitPool(voluntaryExitPool).syncCommitteeContributionPool(syncCommitteeContributionPool).build();
    new BeaconRestApi(dataProvider, beaconRestApiConfig, eventChannels, new StubAsyncRunner(), app);
}
Also used : DataProvider(tech.pegasys.teku.api.DataProvider) StubAsyncRunner(tech.pegasys.teku.infrastructure.async.StubAsyncRunner) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DataProvider

use of tech.pegasys.teku.api.DataProvider in project teku by ConsenSys.

the class BeaconChainController method initRestAPI.

public void initRestAPI() {
    LOG.debug("BeaconChainController.initRestAPI()");
    final DataProvider dataProvider = DataProvider.builder().spec(spec).recentChainData(recentChainData).combinedChainDataClient(combinedChainDataClient).p2pNetwork(p2pNetwork).syncService(syncService).validatorApiChannel(eventChannels.getPublisher(ValidatorApiChannel.class, beaconAsyncRunner)).attestationPool(attestationPool).blockManager(blockManager).attestationManager(attestationManager).isLivenessTrackingEnabled(beaconConfig.beaconRestApiConfig().isBeaconLivenessTrackingEnabled()).activeValidatorChannel(eventChannels.getPublisher(ActiveValidatorChannel.class, beaconAsyncRunner)).attesterSlashingPool(attesterSlashingPool).proposerSlashingPool(proposerSlashingPool).voluntaryExitPool(voluntaryExitPool).syncCommitteeContributionPool(syncCommitteeContributionPool).payloadAttributesCalculator(Optional.of(forkChoiceNotifier.getPayloadAttributesCalculator())).build();
    if (beaconConfig.beaconRestApiConfig().isRestApiEnabled()) {
        beaconRestAPI = Optional.of(new BeaconRestApi(dataProvider, beaconConfig.beaconRestApiConfig(), eventChannels, eventAsyncRunner));
        if (beaconConfig.beaconRestApiConfig().isBeaconLivenessTrackingEnabled()) {
            final int initialValidatorsCount = spec.getGenesisSpec().getConfig().getMinGenesisActiveValidatorCount();
            eventChannels.subscribe(ActiveValidatorChannel.class, new ActiveValidatorCache(spec, initialValidatorsCount));
        }
    } else {
        LOG.info("rest-api-enabled is false, not starting rest api.");
    }
}
Also used : ChainDataProvider(tech.pegasys.teku.api.ChainDataProvider) DataProvider(tech.pegasys.teku.api.DataProvider) ActiveValidatorCache(tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorCache) ActiveValidatorChannel(tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel) BeaconRestApi(tech.pegasys.teku.beaconrestapi.BeaconRestApi) AnchorPoint(tech.pegasys.teku.spec.datastructures.state.AnchorPoint)

Aggregations

DataProvider (tech.pegasys.teku.api.DataProvider)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 StubAsyncRunner (tech.pegasys.teku.infrastructure.async.StubAsyncRunner)2 ChainDataProvider (tech.pegasys.teku.api.ChainDataProvider)1 BeaconRestApi (tech.pegasys.teku.beaconrestapi.BeaconRestApi)1 Eth1Address (tech.pegasys.teku.spec.datastructures.eth1.Eth1Address)1 AnchorPoint (tech.pegasys.teku.spec.datastructures.state.AnchorPoint)1 ActiveValidatorCache (tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorCache)1 ActiveValidatorChannel (tech.pegasys.teku.statetransition.validatorcache.ActiveValidatorChannel)1