Search in sources :

Example 1 with GetSpecResponse

use of tech.pegasys.teku.api.response.v1.config.GetSpecResponse in project teku by ConsenSys.

the class ConfigProvider method getConfig.

public GetSpecResponse getConfig() {
    final Map<String, String> configAttributes = new HashMap<>();
    final SpecConfig config = spec.atEpoch(UInt64.ZERO).getConfig();
    config.getRawConfig().forEach((k, v) -> {
        configAttributes.put(k, formatValue(v));
    });
    // For the time being, manually add legacy constants for compatibility reasons
    // These constants are no longer defined in newer config files, but may be required by consumers
    configAttributes.put("BLS_WITHDRAWAL_PREFIX", config.getBlsWithdrawalPrefix().toHexString());
    configAttributes.put("TARGET_AGGREGATORS_PER_COMMITTEE", Integer.toString(ValidatorConstants.TARGET_AGGREGATORS_PER_COMMITTEE, 10));
    configAttributes.put("RANDOM_SUBNETS_PER_VALIDATOR", Integer.toString(ValidatorConstants.RANDOM_SUBNETS_PER_VALIDATOR, 10));
    configAttributes.put("EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION", Integer.toString(ValidatorConstants.EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, 10));
    configAttributes.put("DOMAIN_BEACON_PROPOSER", Domain.BEACON_PROPOSER.toHexString());
    configAttributes.put("DOMAIN_BEACON_ATTESTER", Domain.BEACON_ATTESTER.toHexString());
    configAttributes.put("DOMAIN_RANDAO", Domain.RANDAO.toHexString());
    configAttributes.put("DOMAIN_DEPOSIT", Domain.DEPOSIT.toHexString());
    configAttributes.put("DOMAIN_VOLUNTARY_EXIT", Domain.VOLUNTARY_EXIT.toHexString());
    configAttributes.put("DOMAIN_SELECTION_PROOF", Domain.SELECTION_PROOF.toHexString());
    configAttributes.put("DOMAIN_AGGREGATE_AND_PROOF", Domain.AGGREGATE_AND_PROOF.toHexString());
    // Manually add legacy altair constants
    config.toVersionAltair().ifPresent(altairConfig -> {
        configAttributes.put("DOMAIN_SYNC_COMMITTEE", Domain.SYNC_COMMITTEE.toHexString());
        configAttributes.put("DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF", Domain.SYNC_COMMITTEE_SELECTION_PROOF.toHexString());
        configAttributes.put("DOMAIN_CONTRIBUTION_AND_PROOF", Domain.CONTRIBUTION_AND_PROOF.toHexString());
        configAttributes.put("TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE", Integer.toString(ValidatorConstants.TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, 10));
        configAttributes.put("SYNC_COMMITTEE_SUBNET_COUNT", Integer.toString(NetworkConstants.SYNC_COMMITTEE_SUBNET_COUNT, 10));
    });
    return new GetSpecResponse(configAttributes);
}
Also used : GetSpecResponse(tech.pegasys.teku.api.response.v1.config.GetSpecResponse) HashMap(java.util.HashMap) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig)

Example 2 with GetSpecResponse

use of tech.pegasys.teku.api.response.v1.config.GetSpecResponse in project teku by ConsenSys.

the class ConfigProviderTest method shouldParseResultOfConfig.

@Test
void shouldParseResultOfConfig() {
    final GetSpecResponse response = configProvider.getConfig();
    final SpecConfig specConfig = SpecConfigLoader.loadRemoteConfig(response.data);
    final SpecConfig expectedConfig = spec.getGenesisSpecConfig();
    assertThat(specConfig).isEqualToComparingFieldByField(expectedConfig);
}
Also used : GetSpecResponse(tech.pegasys.teku.api.response.v1.config.GetSpecResponse) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Test(org.junit.jupiter.api.Test)

Example 3 with GetSpecResponse

use of tech.pegasys.teku.api.response.v1.config.GetSpecResponse in project teku by ConsenSys.

the class RemoteSpecLoaderTest method shouldIgnoreUnknownConfigItems.

@Test
void shouldIgnoreUnknownConfigItems() {
    final Map<String, String> rawConfig = getRawConfigForSpec(spec);
    rawConfig.put("UNKNOWN_ITEM", "foo");
    when(apiClient.getConfigSpec()).thenReturn(Optional.of(new GetSpecResponse(rawConfig)));
    final Spec result = RemoteSpecLoader.getSpec(apiClient);
    assertThat(getRawConfigForSpec(result)).containsExactlyInAnyOrderEntriesOf(rawConfig);
    assertThat(result.getGenesisSpecConfig()).isEqualTo(spec.getGenesisSpecConfig());
}
Also used : GetSpecResponse(tech.pegasys.teku.api.response.v1.config.GetSpecResponse) Spec(tech.pegasys.teku.spec.Spec) Test(org.junit.jupiter.api.Test)

Aggregations

GetSpecResponse (tech.pegasys.teku.api.response.v1.config.GetSpecResponse)3 Test (org.junit.jupiter.api.Test)2 SpecConfig (tech.pegasys.teku.spec.config.SpecConfig)2 HashMap (java.util.HashMap)1 Spec (tech.pegasys.teku.spec.Spec)1