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);
}
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);
}
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);
}
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);
}
Aggregations