diff --git a/platform-sdk/docs/core/wiring-diagram.svg b/platform-sdk/docs/core/wiring-diagram.svg index 05913d6c4929..1e314abde54d 100644 --- a/platform-sdk/docs/core/wiring-diagram.svg +++ b/platform-sdk/docs/core/wiring-diagram.svg @@ -1 +1 @@ -
Transaction Handling
State Verification
State Signature Collection
State File Management
Preconsensus Event Stream
PCES Replay
Miscellaneous
Event Intake
Event Creation
Consensus
Branch Detection
❔🌀
Consensus Engine
❔🚦
🌀
🚽
EventCreationManager
❔❤️🌀🏥🚦
TransactionPool
♻️❔🏥🖋️🚦
♻️
⚰️
PostHashCollector
Mystery Input
RunningEventHashOverride
❤️
🏥
💨
🚦
PcesWriter
✅❔🌀📀🚽
💾
📀
latestCompleteStateNexus
🌀
💢
ISS Detector
💀
💥
🖋️
latestImmutableStateNexus
gossip
❔🌀🏥📬🚦
notifier
❔💢💥🚦
🍎
📝
📬
🔮
🔰
consensus events
rounds
rounds
event window
flush request
future hash
self events
get transactions
GossipEvent
GossipEvent
unordered events
health info
check system health
checkSignedStates
evaluate status
heartbeat
PlatformStatusAction
IssNotification
non-deduplicated events
mystery data
checkForBranches
GossipEvent
unsequenced event
GossipEvent
GossipEvent
events to gossip
preconsensus signatures
GossipEvent
events to write
durable event info
non-validated events
handleConsensusRound
hash override
self events
stale events
publishStaleEvent
non-validated events
hashed states
handleStateAndRound
consensus events
hashed states
signState
states
complete state
complete state notification
state written notification
PlatformStatusAction
minimum identifier to store
submit transaction
PlatformStatus
unhashed state and round
registerState
setState
submit transaction
futures
unhashed event
unhashed event
done streaming pces
\ No newline at end of file +
Transaction Handling
State Verification
State Signature Collection
State File Management
Preconsensus Event Stream
PCES Replay
Miscellaneous
Event Intake
Event Creation
Consensus
AppNotifier
❔💢💥🚦
Branch Detection
❔🌀
Consensus Engine
❔🚦
🌀
🚽
EventCreationManager
❔❤️🌀🏥🚦
TransactionPool
♻️❔🏥🖋️🚦
♻️
⚰️
PostHashCollector
Mystery Input
❤️
🏥
💨
🚦
PcesWriter
✅❔🌀📀🚽
💾
📀
State Signature Collector
❔🔰
💢
ISS Detector
💀
💥
🖋️
Transaction Handler
💨🔮
gossip
❔🌀🏥📬🚦
🍎
📝
📬
🔮
🔰
consensus events
rounds
rounds
event window
flush request
future hash
self events
get transactions
GossipEvent
GossipEvent
unordered events
health info
check system health
checkSignedStates
evaluate status
heartbeat
PlatformStatusAction
IssNotification
non-deduplicated events
mystery data
checkForBranches
GossipEvent
unsequenced event
GossipEvent
GossipEvent
events to gossip
preconsensus signatures
GossipEvent
events to write
durable event info
non-validated events
handleConsensusRound
hash override
self events
stale events
publishStaleEvent
non-validated events
hashed states
handleStateAndRound
consensus events
hashed states
signState
complete state
states
complete state notification
state written notification
PlatformStatusAction
minimum identifier to store
submit transaction
PlatformStatus
setState
unhashed state and round
registerState
submit transaction
futures
unhashed event
unhashed event
done streaming pces
\ No newline at end of file diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java index 9d5d5f8806e3..757f988c2dd2 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java @@ -41,8 +41,6 @@ import com.swirlds.platform.components.DefaultSavedStateController; import com.swirlds.platform.components.EventWindowManager; import com.swirlds.platform.components.SavedStateController; -import com.swirlds.platform.components.appcomm.DefaultLatestCompleteStateNotifier; -import com.swirlds.platform.components.appcomm.LatestCompleteStateNotifier; import com.swirlds.platform.config.StateConfig; import com.swirlds.platform.consensus.EventWindow; import com.swirlds.platform.crypto.KeysAndCerts; @@ -232,8 +230,6 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) { final StateSignatureCollector stateSignatureCollector = new DefaultStateSignatureCollector(platformContext, signedStateMetrics); - final LatestCompleteStateNotifier latestCompleteStateNotifier = new DefaultLatestCompleteStateNotifier(); - blocks.statusActionSubmitterReference() .set(x -> platformWiring.getStatusActionSubmitter().submitStatusAction(x)); @@ -285,7 +281,6 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) { stateSignatureCollector, eventWindowManager, birthRoundMigrationShim, - latestCompleteStateNotifier, latestImmutableStateNexus, latestCompleteStateNexus, savedStateController, diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java index d73bac3d3893..4f6c0a47aaba 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java @@ -24,6 +24,8 @@ import com.swirlds.common.merkle.utility.SerializableLong; import com.swirlds.common.threading.manager.AdHocThreadManager; import com.swirlds.platform.SwirldsPlatform; +import com.swirlds.platform.components.appcomm.DefaultLatestCompleteStateNotifier; +import com.swirlds.platform.components.appcomm.LatestCompleteStateNotifier; import com.swirlds.platform.components.consensus.ConsensusEngine; import com.swirlds.platform.components.consensus.DefaultConsensusEngine; import com.swirlds.platform.config.StateConfig; @@ -152,6 +154,7 @@ public class PlatformComponentBuilder { private BranchReporter branchReporter; private StateSigner stateSigner; private TransactionHandler transactionHandler; + private LatestCompleteStateNotifier latestCompleteStateNotifier; private boolean metricsDocumentationEnabled = true; @@ -1269,4 +1272,37 @@ public TransactionHandler buildTransactionHandler() { } return transactionHandler; } + + /** + * Provide a latest complete state notifier in place of the platform's default latest complete state notifier. + * + * @param latestCompleteStateNotifier the latest complete state notifier to use + * @return this builder + */ + @NonNull + public PlatformComponentBuilder withLatestCompleteStateNotifier( + @NonNull final LatestCompleteStateNotifier latestCompleteStateNotifier) { + throwIfAlreadyUsed(); + if (this.latestCompleteStateNotifier != null) { + throw new IllegalStateException("Latest complete state notifier has already been set"); + } + this.latestCompleteStateNotifier = Objects.requireNonNull(latestCompleteStateNotifier); + return this; + } + + /** + * Build the latest complete state notifier if it has not yet been built. If one has been provided via + * {@link #withLatestCompleteStateNotifier(LatestCompleteStateNotifier)}, that notifier will be used. If this method + * is called more than once, only the first call will build the latest complete state notifier. Otherwise, the + * default notifier will be created and returned. + * + * @return the latest complete state notifier + */ + @NonNull + public LatestCompleteStateNotifier buildLatestCompleteStateNotifier() { + if (latestCompleteStateNotifier == null) { + latestCompleteStateNotifier = new DefaultLatestCompleteStateNotifier(); + } + return latestCompleteStateNotifier; + } } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/nexus/SignedStateNexus.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/nexus/SignedStateNexus.java index 970fa6690847..4d83c6bf6fbc 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/nexus/SignedStateNexus.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/nexus/SignedStateNexus.java @@ -17,6 +17,7 @@ package com.swirlds.platform.state.nexus; import com.swirlds.common.utility.Clearable; +import com.swirlds.common.wiring.component.SchedulerLabel; import com.swirlds.platform.consensus.ConsensusConstants; import com.swirlds.platform.state.signed.ReservedSignedState; import edu.umd.cs.findbugs.annotations.NonNull; @@ -25,6 +26,7 @@ /** * A thread-safe container that also manages reservations for a single signed state. */ +@SchedulerLabel("LatestImmutableStateNexus") public interface SignedStateNexus extends Clearable { /** * Returns the current signed state and reserves it. If the current signed state is null, or cannot be reserved, diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulers.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulers.java deleted file mode 100644 index 5f02860aa5ab..000000000000 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulers.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.swirlds.platform.wiring; - -import static com.swirlds.common.wiring.model.diagram.HyperlinkBuilder.platformCoreHyperlink; - -import com.swirlds.common.context.PlatformContext; -import com.swirlds.common.stream.RunningEventHashOverride; -import com.swirlds.common.wiring.model.WiringModel; -import com.swirlds.common.wiring.schedulers.TaskScheduler; -import com.swirlds.common.wiring.schedulers.builders.TaskSchedulerType; -import com.swirlds.platform.event.preconsensus.PcesReplayer; -import edu.umd.cs.findbugs.annotations.NonNull; - -/** - * The {@link TaskScheduler}s used by the platform. - *

- * This class is being phased out. Do not add additional schedulers to this class! - * - * @param pcesReplayerScheduler the scheduler for the pces replayer - * @param runningHashUpdateScheduler the scheduler for the running hash updater - * @param latestCompleteStateNotifierScheduler the scheduler for the latest complete state notifier - */ -public record PlatformSchedulers( - @NonNull TaskScheduler pcesReplayerScheduler, - @NonNull TaskScheduler runningHashUpdateScheduler, - @NonNull TaskScheduler latestCompleteStateNotifierScheduler) { - - /** - * Instantiate the schedulers for the platform, for the given wiring model - * - * @param context the platform context - * @param model the wiring model - * @return the instantiated platform schedulers - */ - public static PlatformSchedulers create(@NonNull final PlatformContext context, @NonNull final WiringModel model) { - final PlatformSchedulersConfig config = - context.getConfiguration().getConfigData(PlatformSchedulersConfig.class); - - return new PlatformSchedulers( - model.schedulerBuilder("pcesReplayer") - .withType(TaskSchedulerType.DIRECT) - .withHyperlink(platformCoreHyperlink(PcesReplayer.class)) - .build() - .cast(), - model.schedulerBuilder("RunningEventHashOverride") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast(), - model.schedulerBuilder("latestCompleteStateNotifier") - .withType(TaskSchedulerType.SEQUENTIAL_THREAD) - .withUnhandledTaskCapacity(config.completeStateNotifierUnhandledCapacity()) - .withUnhandledTaskMetricEnabled(true) - .build() - .cast()); - } -} diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulersConfig.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulersConfig.java index e49d0078c4ff..4591e549e550 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulersConfig.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformSchedulersConfig.java @@ -24,43 +24,43 @@ /** * Contains configuration values for the platform schedulers. * - * @param eventHasherUnhandledCapacity number of unhandled tasks allowed in the event hasher scheduler - * @param internalEventValidator configuration for the internal event validator scheduler - * @param eventDeduplicator configuration for the event deduplicator scheduler - * @param eventSignatureValidator configuration for the event signature validator scheduler - * @param orphanBuffer configuration for the orphan buffer scheduler - * @param consensusEngine configuration for the consensus engine scheduler - * @param eventCreationManager configuration for the event creation manager scheduler - * @param selfEventSigner configuration for the self event signer scheduler - * @param stateSigner configuration for the state signer scheduler - * @param pcesWriter configuration for the preconsensus event writer scheduler - * @param pcesSequencer configuration for the preconsensus event sequencer scheduler - * @param applicationTransactionPrehandler configuration for the application transaction prehandler scheduler - * @param stateSignatureCollector configuration for the state signature collector scheduler - * @param transactionHandler configuration for the transaction handler scheduler - * @param issDetector configuration for the ISS detector scheduler - * @param issHandler configuration for the ISS handler scheduler - * @param hashLogger configuration for the hash logger scheduler - * @param completeStateNotifierUnhandledCapacity number of unhandled tasks allowed for the state completion notifier - * @param stateHasher configuration for the state hasher scheduler - * @param stateGarbageCollector configuration for the state garbage collector scheduler - * @param stateGarbageCollectorHeartbeatPeriod the frequency that heartbeats should be sent to the state garbage - * collector - * @param platformPublisher configuration for the platform publisher scheduler - * @param consensusEventStream configuration for the consensus event stream scheduler - * @param roundDurabilityBuffer configuration for the round durability buffer scheduler - * @param signedStateSentinel configuration for the signed state sentinel scheduler - * @param signedStateSentinelHeartbeatPeriod the frequency that heartbeats should be sent to the signed state - * sentinel - * @param statusStateMachine configuration for the status state machine scheduler - * @param staleEventDetector configuration for the stale event detector scheduler - * @param transactionResubmitter configuration for the transaction resubmitter scheduler - * @param transactionPool configuration for the transaction pool scheduler - * @param gossip configuration for the gossip scheduler - * @param eventHasher configuration for the event hasher scheduler - * @param postHashCollector configuration for the post hash collector scheduler - * @param branchDetector configuration for the branch detector scheduler - * @param branchReporter configuration for the branch reporter scheduler + * @param eventHasherUnhandledCapacity number of unhandled tasks allowed in the event hasher scheduler + * @param internalEventValidator configuration for the internal event validator scheduler + * @param eventDeduplicator configuration for the event deduplicator scheduler + * @param eventSignatureValidator configuration for the event signature validator scheduler + * @param orphanBuffer configuration for the orphan buffer scheduler + * @param consensusEngine configuration for the consensus engine scheduler + * @param eventCreationManager configuration for the event creation manager scheduler + * @param selfEventSigner configuration for the self event signer scheduler + * @param stateSigner configuration for the state signer scheduler + * @param pcesWriter configuration for the preconsensus event writer scheduler + * @param pcesSequencer configuration for the preconsensus event sequencer scheduler + * @param applicationTransactionPrehandler configuration for the application transaction prehandler scheduler + * @param stateSignatureCollector configuration for the state signature collector scheduler + * @param transactionHandler configuration for the transaction handler scheduler + * @param issDetector configuration for the ISS detector scheduler + * @param issHandler configuration for the ISS handler scheduler + * @param hashLogger configuration for the hash logger scheduler + * @param latestCompleteStateNotifier configuration for the latest complete state notifier scheduler + * @param stateHasher configuration for the state hasher scheduler + * @param stateGarbageCollector configuration for the state garbage collector scheduler + * @param stateGarbageCollectorHeartbeatPeriod the frequency that heartbeats should be sent to the state garbage + * collector + * @param platformPublisher configuration for the platform publisher scheduler + * @param consensusEventStream configuration for the consensus event stream scheduler + * @param roundDurabilityBuffer configuration for the round durability buffer scheduler + * @param signedStateSentinel configuration for the signed state sentinel scheduler + * @param signedStateSentinelHeartbeatPeriod the frequency that heartbeats should be sent to the signed state + * sentinel + * @param statusStateMachine configuration for the status state machine scheduler + * @param staleEventDetector configuration for the stale event detector scheduler + * @param transactionResubmitter configuration for the transaction resubmitter scheduler + * @param transactionPool configuration for the transaction pool scheduler + * @param gossip configuration for the gossip scheduler + * @param eventHasher configuration for the event hasher scheduler + * @param postHashCollector configuration for the post hash collector scheduler + * @param branchDetector configuration for the branch detector scheduler + * @param branchReporter configuration for the branch reporter scheduler */ @ConfigData("platformSchedulers") public record PlatformSchedulersConfig( @@ -100,7 +100,8 @@ public record PlatformSchedulersConfig( @ConfigProperty(defaultValue = "DIRECT") TaskSchedulerConfiguration issHandler, @ConfigProperty(defaultValue = "SEQUENTIAL CAPACITY(100) UNHANDLED_TASK_METRIC") TaskSchedulerConfiguration hashLogger, - @ConfigProperty(defaultValue = "1000") int completeStateNotifierUnhandledCapacity, + @ConfigProperty(defaultValue = "SEQUENTIAL CAPACITY(5) UNHANDLED_TASK_METRIC") + TaskSchedulerConfiguration latestCompleteStateNotifier, @ConfigProperty( defaultValue = "SEQUENTIAL_THREAD CAPACITY(5) FLUSHABLE UNHANDLED_TASK_METRIC BUSY_FRACTION_METRIC") diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformWiring.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformWiring.java index 5f3381a9e45a..d572c8c45a4e 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformWiring.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/PlatformWiring.java @@ -17,6 +17,7 @@ package com.swirlds.platform.wiring; import static com.swirlds.common.wiring.model.diagram.HyperlinkBuilder.platformCoreHyperlink; +import static com.swirlds.common.wiring.schedulers.builders.TaskSchedulerConfiguration.DIRECT_THREADSAFE_CONFIGURATION; import static com.swirlds.common.wiring.schedulers.builders.TaskSchedulerConfiguration.NO_OP_CONFIGURATION; import static com.swirlds.common.wiring.wires.SolderType.INJECT; import static com.swirlds.common.wiring.wires.SolderType.OFFER; @@ -34,7 +35,6 @@ import com.swirlds.common.wiring.schedulers.TaskScheduler; import com.swirlds.common.wiring.schedulers.builders.TaskSchedulerBuilder; import com.swirlds.common.wiring.schedulers.builders.TaskSchedulerConfiguration; -import com.swirlds.common.wiring.schedulers.builders.TaskSchedulerType; import com.swirlds.common.wiring.transformers.RoutableData; import com.swirlds.common.wiring.transformers.WireFilter; import com.swirlds.common.wiring.transformers.WireTransformer; @@ -195,20 +195,13 @@ public PlatformWiring( config = platformContext.getConfiguration().getConfigData(PlatformSchedulersConfig.class); hashCollectorEnabled = config.hashCollectorEnabled(); - final PlatformSchedulers schedulers = PlatformSchedulers.create(platformContext, model); - final AncientMode ancientMode = platformContext .getConfiguration() .getConfigData(EventConfig.class) .getAncientMode(); if (ancientMode == AncientMode.BIRTH_ROUND_THRESHOLD) { - birthRoundMigrationShimWiring = new ComponentWiring<>( - model, - BirthRoundMigrationShim.class, - model.schedulerBuilder("birthRoundMigrationShim") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast()); + birthRoundMigrationShimWiring = + new ComponentWiring<>(model, BirthRoundMigrationShim.class, DIRECT_THREADSAFE_CONFIGURATION); } else { birthRoundMigrationShimWiring = null; } @@ -260,65 +253,36 @@ public PlatformWiring( transactionHandlerWiring = new ComponentWiring<>(model, TransactionHandler.class, config.transactionHandler()); consensusEventStreamWiring = new ComponentWiring<>(model, ConsensusEventStream.class, config.consensusEventStream()); - runningEventHashOverrideWiring = RunningEventHashOverrideWiring.create(schedulers.runningHashUpdateScheduler()); + runningEventHashOverrideWiring = RunningEventHashOverrideWiring.create(model); stateHasherWiring = new ComponentWiring<>(model, StateHasher.class, config.stateHasher()); gossipWiring = new GossipWiring(platformContext, model); - pcesReplayerWiring = PcesReplayerWiring.create(schedulers.pcesReplayerScheduler()); + pcesReplayerWiring = PcesReplayerWiring.create(model); pcesWriterWiring = new ComponentWiring<>(model, PcesWriter.class, config.pcesWriter()); roundDurabilityBufferWiring = new ComponentWiring<>(model, RoundDurabilityBuffer.class, config.roundDurabilityBuffer()); - eventWindowManagerWiring = new ComponentWiring<>( - model, - EventWindowManager.class, - model.schedulerBuilder("eventWindowManager") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .withHyperlink(platformCoreHyperlink(EventWindowManager.class)) - .build() - .cast()); + eventWindowManagerWiring = + new ComponentWiring<>(model, EventWindowManager.class, DIRECT_THREADSAFE_CONFIGURATION); issDetectorWiring = new ComponentWiring<>(model, IssDetector.class, config.issDetector()); issHandlerWiring = new ComponentWiring<>(model, IssHandler.class, config.issHandler()); hashLoggerWiring = new ComponentWiring<>(model, HashLogger.class, config.hashLogger()); - latestCompleteStateNotifierWiring = new ComponentWiring<>( - model, - LatestCompleteStateNotifier.class, - schedulers.latestCompleteStateNotifierScheduler().cast()); - - latestImmutableStateNexusWiring = new ComponentWiring<>( - model, - SignedStateNexus.class, - model.schedulerBuilder("latestImmutableStateNexus") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast()); - latestCompleteStateNexusWiring = new ComponentWiring<>( - model, - LatestCompleteStateNexus.class, - model.schedulerBuilder("latestCompleteStateNexus") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast()); - savedStateControllerWiring = new ComponentWiring<>( - model, - SavedStateController.class, - model.schedulerBuilder("savedStateController") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast()); - - notifierWiring = new ComponentWiring<>( - model, - AppNotifier.class, - model.schedulerBuilder("notifier") - .withType(TaskSchedulerType.DIRECT_THREADSAFE) - .build() - .cast()); + latestCompleteStateNotifierWiring = + new ComponentWiring<>(model, LatestCompleteStateNotifier.class, config.latestCompleteStateNotifier()); + + latestImmutableStateNexusWiring = + new ComponentWiring<>(model, SignedStateNexus.class, DIRECT_THREADSAFE_CONFIGURATION); + latestCompleteStateNexusWiring = + new ComponentWiring<>(model, LatestCompleteStateNexus.class, DIRECT_THREADSAFE_CONFIGURATION); + savedStateControllerWiring = + new ComponentWiring<>(model, SavedStateController.class, DIRECT_THREADSAFE_CONFIGURATION); + + notifierWiring = new ComponentWiring<>(model, AppNotifier.class, DIRECT_THREADSAFE_CONFIGURATION); this.publishPreconsensusEvents = applicationCallbacks.preconsensusEventConsumer() != null; this.publishSnapshotOverrides = applicationCallbacks.snapshotOverrideConsumer() != null; @@ -819,7 +783,6 @@ private void buildUnsolderedWires() { * @param eventWindowManager the event window manager to bind * @param birthRoundMigrationShim the birth round migration shim to bind, ignored if birth round migration has not * yet happened, must not be null if birth round migration has happened - * @param completeStateNotifier the latest complete state notifier to bind * @param latestImmutableStateNexus the latest immutable state nexus to bind * @param latestCompleteStateNexus the latest complete state nexus to bind * @param savedStateController the saved state controller to bind @@ -832,7 +795,6 @@ public void bind( @NonNull final StateSignatureCollector stateSignatureCollector, @NonNull final EventWindowManager eventWindowManager, @Nullable final BirthRoundMigrationShim birthRoundMigrationShim, - @NonNull final LatestCompleteStateNotifier completeStateNotifier, @NonNull final SignedStateNexus latestImmutableStateNexus, @NonNull final LatestCompleteStateNexus latestCompleteStateNexus, @NonNull final SavedStateController savedStateController, @@ -864,7 +826,7 @@ public void bind( if (birthRoundMigrationShimWiring != null) { birthRoundMigrationShimWiring.bind(Objects.requireNonNull(birthRoundMigrationShim)); } - latestCompleteStateNotifierWiring.bind(completeStateNotifier); + latestCompleteStateNotifierWiring.bind(builder::buildLatestCompleteStateNotifier); latestImmutableStateNexusWiring.bind(latestImmutableStateNexus); latestCompleteStateNexusWiring.bind(latestCompleteStateNexus); savedStateControllerWiring.bind(savedStateController); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/PcesReplayerWiring.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/PcesReplayerWiring.java index 8feeb602a075..4e95351e2036 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/PcesReplayerWiring.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/PcesReplayerWiring.java @@ -16,7 +16,11 @@ package com.swirlds.platform.wiring.components; +import static com.swirlds.common.wiring.model.diagram.HyperlinkBuilder.platformCoreHyperlink; +import static com.swirlds.common.wiring.schedulers.builders.TaskSchedulerType.DIRECT; + import com.swirlds.common.io.IOIterator; +import com.swirlds.common.wiring.model.WiringModel; import com.swirlds.common.wiring.schedulers.TaskScheduler; import com.swirlds.common.wiring.wires.input.BindableInputWire; import com.swirlds.common.wiring.wires.input.InputWire; @@ -43,11 +47,17 @@ public record PcesReplayerWiring( /** * Create a new instance of this wiring. * - * @param taskScheduler the task scheduler for this wiring + * @param model the wiring model * @return the new wiring instance */ @NonNull - public static PcesReplayerWiring create(@NonNull final TaskScheduler taskScheduler) { + public static PcesReplayerWiring create(@NonNull final WiringModel model) { + final TaskScheduler taskScheduler = model.schedulerBuilder("pcesReplayer") + .withType(DIRECT) + .withHyperlink(platformCoreHyperlink(PcesReplayer.class)) + .build() + .cast(); + return new PcesReplayerWiring( taskScheduler.buildInputWire("event files to replay"), taskScheduler.getOutputWire(), diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/RunningEventHashOverrideWiring.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/RunningEventHashOverrideWiring.java index c52e776f30e0..d9f08797d867 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/RunningEventHashOverrideWiring.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/components/RunningEventHashOverrideWiring.java @@ -16,7 +16,11 @@ package com.swirlds.platform.wiring.components; +import static com.swirlds.common.wiring.model.diagram.HyperlinkBuilder.platformCoreHyperlink; +import static com.swirlds.common.wiring.schedulers.builders.TaskSchedulerType.DIRECT_THREADSAFE; + import com.swirlds.common.stream.RunningEventHashOverride; +import com.swirlds.common.wiring.model.WiringModel; import com.swirlds.common.wiring.schedulers.TaskScheduler; import com.swirlds.common.wiring.wires.input.BindableInputWire; import com.swirlds.common.wiring.wires.input.InputWire; @@ -36,12 +40,17 @@ public record RunningEventHashOverrideWiring( /** * Create a new wiring object * - * @param taskScheduler the task scheduler to use + * @param model the wiring model * @return the new wiring object */ @NonNull - public static RunningEventHashOverrideWiring create( - @NonNull final TaskScheduler taskScheduler) { + public static RunningEventHashOverrideWiring create(@NonNull final WiringModel model) { + + final TaskScheduler taskScheduler = model.schedulerBuilder("RunningEventHashOverride") + .withType(DIRECT_THREADSAFE) + .withHyperlink(platformCoreHyperlink(RunningEventHashOverrideWiring.class)) + .build() + .cast(); final BindableInputWire inputWire = taskScheduler.buildInputWire("hash override"); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/generate-platform-diagram.sh b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/generate-platform-diagram.sh index c85579e369d1..b582aac81cba 100755 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/generate-platform-diagram.sh +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/wiring/generate-platform-diagram.sh @@ -12,7 +12,7 @@ pcli diagram \ -l 'TransactionPrehandler:futures:TransactionHandler' \ -l 'EventCreationManager:get transactions:TransactionPool' \ -l 'ConsensusEventStream:future hash:TransactionHandler' \ - -s 'eventWindowManager:event window:🌀' \ + -s 'EventWindowManager:event window:🌀' \ -s 'Heartbeat:heartbeat:❤️' \ -s 'TransactionPrehandler:futures:🔮' \ -s 'pcesReplayer:done streaming pces:✅' \ @@ -25,7 +25,7 @@ pcli diagram \ -s 'StateSigner:signature transactions:🖋️' \ -s 'IssDetectorSplitter:IssNotification:💥' \ -s 'getStatusAction:PlatformStatusAction:💀' \ - -s 'latestCompleteStateNotifier:complete state notification:💢' \ + -s 'LatestCompleteStateNotifier:complete state notification:💢' \ -s 'OrphanBufferSplitter:preconsensus signatures:🔰' \ -s 'RunningEventHashOverride:hash override:💨' \ -s 'TransactionResubmitterSplitter:submit transaction:♻️' \ @@ -36,22 +36,22 @@ pcli diagram \ -s 'HealthMonitor:health info:🏥' \ -g 'Orphan Buffer:OrphanBuffer,OrphanBufferSplitter' \ -g 'Event Intake:EventHasher,InternalEventValidator,EventDeduplicator,EventSignatureValidator,Orphan Buffer,PostHashCollector' \ - -g 'Consensus Engine:ConsensusEngine,ConsensusEngineSplitter,eventWindowManager,getKeystoneEventSequenceNumber,getConsensusEvents' \ + -g 'Consensus Engine:ConsensusEngine,ConsensusEngineSplitter,EventWindowManager,getKeystoneEventSequenceNumber,getConsensusEvents' \ -g 'State Snapshot Manager:saveToDiskFilter,StateSnapshotManager,extractOldestMinimumGenerationOnDisk,toStateWrittenToDiskAction,toNotification' \ -g 'State File Management:State Snapshot Manager,📀,💾' \ - -g 'State Signature Collector:StateSignatureCollector,reservedStateSplitter,allStatesReserver,completeStateFilter,completeStatesReserver,extractConsensusSignatureTransactions,extractPreconsensusSignatureTransactions,latestCompleteStateNotifier' \ - -g 'State Signature Collection:State Signature Collector,latestCompleteStateNexus,💢' \ + -g 'State Signature Collector:StateSignatureCollector,reservedStateSplitter,allStatesReserver,completeStateFilter,completeStatesReserver,extractConsensusSignatureTransactions,extractPreconsensusSignatureTransactions,LatestCompleteStateNotifier' \ + -g 'State Signature Collection:State Signature Collector,LatestCompleteStateNexus,💢' \ -g 'Preconsensus Event Stream:PcesSequencer,PcesWriter' \ -g 'Transaction Resubmitter:TransactionResubmitter,TransactionResubmitterSplitter' \ -g 'Stale Event Detector:StaleEventDetector,StaleEventDetectorSplitter,StaleEventDetectorRouter' \ -g 'Event Creation:EventCreationManager,TransactionPool,SelfEventSigner,Stale Event Detector,Transaction Resubmitter,⚰️,♻️' \ -g 'ISS Detector:IssDetector,IssDetectorSplitter,IssHandler,getStatusAction' \ -g 'PCES Replay:pcesReplayer,✅' \ - -g 'Transaction Handler:TransactionHandler,postHandler_stateAndRoundReserver,getState,savedStateController' \ + -g 'Transaction Handler:TransactionHandler,postHandler_stateAndRoundReserver,getState,SavedStateController' \ -g 'State Hasher:StateHasher,postHasher_stateAndRoundReserver,postHasher_getConsensusRound,postHasher_stateReserver' \ -g 'Consensus:Consensus Engine,🚽,🌀' \ -g 'State Verification:StateSigner,HashLogger,ISS Detector,🖋️,💥,💀' \ - -g 'Transaction Handling:Transaction Handler,latestImmutableStateNexus' \ + -g 'Transaction Handling:Transaction Handler,LatestImmutableStateNexus' \ -g 'Round Durability Buffer:RoundDurabilityBuffer,RoundDurabilityBufferSplitter' \ -g 'Branch Detection:BranchDetector,BranchReporter' \ -g 'Miscellaneous:Mystery Input,RunningEventHashOverride,HealthMonitor,SignedStateSentinel,StatusStateMachine,Heartbeat,❔,🏥,❤️,💨,🚦' \ diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/PlatformWiringTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/PlatformWiringTests.java index 47a3fb9692d7..b48e95739a27 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/PlatformWiringTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/PlatformWiringTests.java @@ -114,7 +114,8 @@ void testBindings() { .withBranchDetector(mock(BranchDetector.class)) .withBranchReporter(mock(BranchReporter.class)) .withStateSigner(mock(StateSigner.class)) - .withTransactionHandler(mock(DefaultTransactionHandler.class)); + .withTransactionHandler(mock(DefaultTransactionHandler.class)) + .withLatestCompleteStateNotifier(mock(LatestCompleteStateNotifier.class)); // Gossip is a special case, it's not like other components. // Currently we just have a facade between gossip and the wiring framework. @@ -145,7 +146,6 @@ void testBindings() { mock(StateSignatureCollector.class), mock(EventWindowManager.class), mock(BirthRoundMigrationShim.class), - mock(LatestCompleteStateNotifier.class), mock(SignedStateNexus.class), mock(LatestCompleteStateNexus.class), mock(SavedStateController.class),