Search in sources :

Example 1 with TransitionConfiguration

use of tech.pegasys.teku.spec.executionengine.TransitionConfiguration in project teku by ConsenSys.

the class TerminalPowBlockMonitorTest method setUpCommon.

private void setUpCommon(Consumer<BellatrixBuilder> bellatrixBuilder) {
    spec = TestSpecFactory.createBellatrix(SpecConfigLoader.loadConfig("minimal", phase0Builder -> phase0Builder.altairBuilder(altairBuilder -> altairBuilder.altairForkEpoch(UInt64.ZERO)).bellatrixBuilder(bellatrixBuilder)));
    dataStructureUtil = new DataStructureUtil(spec);
    storageSystem = InMemoryStorageSystemBuilder.buildDefault(spec);
    storageSystem.chainUpdater().initializeGenesis(false);
    recentChainData = storageSystem.recentChainData();
    localTransitionConfiguration = new TransitionConfiguration(spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalTotalDifficulty(), spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalBlockHash(), UInt64.ZERO);
    terminalPowBlockMonitor = new TerminalPowBlockMonitor(executionEngine, spec, recentChainData, forkChoiceNotifier, asyncRunner, eventLogger);
    terminalPowBlockMonitor.onNodeSyncStateChanged(true);
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

Example 2 with TransitionConfiguration

use of tech.pegasys.teku.spec.executionengine.TransitionConfiguration in project teku by ConsenSys.

the class TerminalPowBlockMonitor method start.

public synchronized void start() {
    if (timer.isPresent()) {
        return;
    }
    Optional<SpecConfigBellatrix> maybeSpecConfigBellatrix = getSpecConfigBellatrix();
    if (maybeSpecConfigBellatrix.isEmpty()) {
        LOG.error("Bellatrix spec config not found. Monitor will shutdown.");
        stop();
        return;
    }
    specConfigBellatrix = maybeSpecConfigBellatrix.get();
    localTransitionConfiguration = new TransitionConfiguration(specConfigBellatrix.getTerminalTotalDifficulty(), specConfigBellatrix.getTerminalBlockHash(), UInt64.ZERO);
    final Duration pollingPeriod = Duration.ofSeconds(spec.getGenesisSpec().getConfig().getSecondsPerEth1Block());
    timer = Optional.of(asyncRunner.runWithFixedDelay(this::monitor, pollingPeriod, (error) -> LOG.error("An error occurred while executing the monitor task", error)));
    LOG.info("Monitor has started. Waiting BELLATRIX fork activation. Polling every {}", pollingPeriod);
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) SpecConfigBellatrix(tech.pegasys.teku.spec.config.SpecConfigBellatrix) Duration(java.time.Duration)

Example 3 with TransitionConfiguration

use of tech.pegasys.teku.spec.executionengine.TransitionConfiguration in project teku by ConsenSys.

the class Web3JExecutionEngineClientTest method shouldTransitionConfigurationRoundtrip.

@TestTemplate
void shouldTransitionConfigurationRoundtrip() {
    final TransitionConfigurationV1 externalTransitionConfiguration = new TransitionConfigurationV1(dataStructureUtil.randomUInt256(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64());
    final TransitionConfiguration internalTransitionConfiguration = externalTransitionConfiguration.asInternalTransitionConfiguration();
    assertThat(internalTransitionConfiguration.getTerminalBlockHash()).isEqualTo(externalTransitionConfiguration.terminalBlockHash);
    assertThat(internalTransitionConfiguration.getTerminalBlockNumber()).isEqualTo(externalTransitionConfiguration.terminalBlockNumber);
    assertThat(internalTransitionConfiguration.getTerminalTotalDifficulty()).isEqualTo(externalTransitionConfiguration.terminalTotalDifficulty);
    final TransitionConfigurationV1 externalTransitionConfiguration2 = TransitionConfigurationV1.fromInternalTransitionConfiguration(internalTransitionConfiguration);
    assertThat(externalTransitionConfiguration2).isEqualTo(externalTransitionConfiguration);
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) TransitionConfigurationV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 4 with TransitionConfiguration

use of tech.pegasys.teku.spec.executionengine.TransitionConfiguration in project teku by ConsenSys.

the class TerminalPowBlockMonitorTest method shouldDetectTerminalConfigProblems.

@Test
void shouldDetectTerminalConfigProblems() {
    setUpTerminalBlockHashConfig();
    final UInt256 wrongRemoteTTD = dataStructureUtil.randomUInt256();
    final Bytes32 wrongRemoteTBH = dataStructureUtil.randomBytes32();
    TransitionConfiguration wrongRemoteConfig;
    terminalPowBlockMonitor.start();
    // wrong TTD
    wrongRemoteConfig = new TransitionConfiguration(wrongRemoteTTD, localTransitionConfiguration.getTerminalBlockHash(), UInt64.ZERO);
    when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)).thenReturn(SafeFuture.completedFuture(wrongRemoteConfig));
    asyncRunner.executeQueuedActions();
    verify(eventLogger).transitionConfigurationTtdTbhMismatch(localTransitionConfiguration.toString(), wrongRemoteConfig.toString());
    // wrong TBH
    wrongRemoteConfig = new TransitionConfiguration(localTransitionConfiguration.getTerminalTotalDifficulty(), wrongRemoteTBH, UInt64.ZERO);
    when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)).thenReturn(SafeFuture.completedFuture(wrongRemoteConfig));
    asyncRunner.executeQueuedActions();
    verify(eventLogger).transitionConfigurationTtdTbhMismatch(localTransitionConfiguration.toString(), wrongRemoteConfig.toString());
    // remote TBH TBN inconsistency
    wrongRemoteConfig = new TransitionConfiguration(localTransitionConfiguration.getTerminalTotalDifficulty(), localTransitionConfiguration.getTerminalBlockHash(), UInt64.ZERO);
    when(executionEngine.exchangeTransitionConfiguration(localTransitionConfiguration)).thenReturn(SafeFuture.completedFuture(wrongRemoteConfig));
    asyncRunner.executeQueuedActions();
    verify(eventLogger).transitionConfigurationRemoteTbhTbnInconsistency(wrongRemoteConfig.toString());
    verifyNoMoreInteractions(eventLogger);
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) Bytes32(org.apache.tuweni.bytes.Bytes32) UInt256(org.apache.tuweni.units.bigints.UInt256) Test(org.junit.jupiter.api.Test)

Aggregations

TransitionConfiguration (tech.pegasys.teku.spec.executionengine.TransitionConfiguration)4 Duration (java.time.Duration)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 UInt256 (org.apache.tuweni.units.bigints.UInt256)1 Test (org.junit.jupiter.api.Test)1 TestTemplate (org.junit.jupiter.api.TestTemplate)1 TransitionConfigurationV1 (tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1)1 SpecConfigBellatrix (tech.pegasys.teku.spec.config.SpecConfigBellatrix)1 DataStructureUtil (tech.pegasys.teku.spec.util.DataStructureUtil)1