Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Notify application when a self-ISS event is detected by the platform #17274

Merged
merged 7 commits into from
Jan 9, 2025
Prev Previous commit
Next Next commit
spotless
Signed-off-by: Tim Farber-Newman <tim.farber-newman@swirldslabs.com>
  • Loading branch information
timfn-hg committed Jan 8, 2025
commit 7409480f13a644d15adc15eb2c67071f5ac843ec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Hedera Hashgraph, LLC
* Copyright (C) 2020-2025 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (C) 2025 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.hedera.node.app.state.listeners;

import com.swirlds.platform.system.state.notifications.AsyncIssListener;
Expand All @@ -13,12 +29,12 @@
private static final Logger log = LogManager.getLogger(IssDetectedListener.class);

@Inject
public IssDetectedListener() {
public IssDetectedListener() {
// no-op
}

@Override
public void notify(final IssNotification data) {
log.warn("ISS detected (type={}, round={})", data.getIssType(), data.getRound());
}

Check warning on line 39 in hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/listeners/IssDetectedListener.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/listeners/IssDetectedListener.java#L38-L39

Added lines #L38 - L39 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -932,8 +932,8 @@
// halt without needing to be stopped here. This should eventually be cleaned up.
},
SystemExitUtils::handleFatalError,
blocks.issScratchpad(),
blocks.notificationEngine());

Check warning on line 936 in platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java

View check run for this annotation

Codecov / codecov/patch

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java#L935-L936

Added lines #L935 - L936 were not covered by tests
}
return issHandler;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
* Copyright (C) 2022-2025 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (C) 2025 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.system.state.notifications;

import com.swirlds.common.notification.DispatchMode;
Expand All @@ -9,4 +25,4 @@
* Async listener for ISS events. If you require ordered, synchronous dispatch use {@link IssListener}.
*/
@DispatchModel(mode = DispatchMode.ASYNC, order = DispatchOrder.UNORDERED)
public interface AsyncIssListener extends Listener<IssNotification> { }
public interface AsyncIssListener extends Listener<IssNotification> {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
* Copyright (C) 2022-2025 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.
Expand Down Expand Up @@ -75,8 +75,8 @@ void otherIssAlwaysFreeze() {

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();

final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

handler.issObserved(new IssNotification(1234L, IssType.OTHER_ISS));

Expand Down Expand Up @@ -112,8 +112,8 @@ void otherIssNoAction() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

handler.issObserved(new IssNotification(1234L, IssType.OTHER_ISS));

Expand Down Expand Up @@ -143,8 +143,8 @@ void selfIssAutomatedRecovery() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

final IssNotification notification = new IssNotification(1234L, IssType.SELF_ISS);
handler.issObserved(notification);
Expand Down Expand Up @@ -177,8 +177,8 @@ void selfIssNoAction() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

final IssNotification notification = new IssNotification(1234L, IssType.SELF_ISS);
handler.issObserved(notification);
Expand Down Expand Up @@ -211,8 +211,8 @@ void selfIssAlwaysFreeze() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

final IssNotification notification = new IssNotification(1234L, IssType.SELF_ISS);
handler.issObserved(notification);
Expand Down Expand Up @@ -251,8 +251,8 @@ void catastrophicIssNoAction() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

handler.issObserved(new IssNotification(1234L, IssType.CATASTROPHIC_ISS));

Expand Down Expand Up @@ -284,8 +284,8 @@ void catastrophicIssAlwaysFreeze() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

handler.issObserved(new IssNotification(1234L, IssType.CATASTROPHIC_ISS));

Expand Down Expand Up @@ -323,8 +323,8 @@ void catastrophicIssFreezeOnCatastrophic() {
final FatalErrorConsumer fatalErrorConsumer = (msg, t, code) -> shutdownCount.getAndIncrement();

final Scratchpad<IssScratchpad> simpleScratchpad = new SimpleScratchpad<>();
final IssHandler handler =
new DefaultIssHandler(platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);
final IssHandler handler = new DefaultIssHandler(
platformContext, haltRequestedConsumer, fatalErrorConsumer, simpleScratchpad, notificationEngine);

handler.issObserved(new IssNotification(1234L, IssType.CATASTROPHIC_ISS));

Expand Down
Loading