Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/docker/setup-qemu-…
Browse files Browse the repository at this point in the history
…action-3.3.0
  • Loading branch information
mishomihov00 authored Jan 10, 2025
2 parents 5390a5a + 45f108d commit 1c690c3
Show file tree
Hide file tree
Showing 31 changed files with 1,272 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/node-zxc-build-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,23 @@ jobs:
cp -rvf ~/artifact-build/* hedera-node/infrastructure/docker/containers/local-node/main-network-node/sdk/
- name: Build Haveged Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
push: true
platforms: linux/amd64,linux/arm64
context: hedera-node/infrastructure/docker/containers/local-node/network-node-haveged
tags: ${{ steps.set-registry.outputs.docker-tag-base }}/network-node-haveged:${{ needs.validate.outputs.version }}

- name: Build Base Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
push: true
platforms: linux/amd64,linux/arm64
context: hedera-node/infrastructure/docker/containers/local-node/network-node-base
tags: ${{ steps.set-registry.outputs.docker-tag-base }}/network-node-base:${{ needs.validate.outputs.version }}

- name: Build Network Node Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
push: true
platforms: linux/amd64,linux/arm64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zxc-publish-production-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
cp -rvf ~/artifact-build/* hedera-node/infrastructure/docker/containers/production-next/consensus-node/sdk/
- name: Build Consensus Node Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
env:
SOURCE_DATE_EPOCH: ${{ steps.commit.outputs.source-date }}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/zxc-verify-docker-build-determinism.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
# Copyright (C) 2023-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 @@ -240,7 +240,7 @@ jobs:
printf "VERSION=%s\nCOMMIT=%s\nDATE=%s" "$(./gradlew -q showVersion)" "$(git log -1 --format='%H' | cut -c1-8)" "$(date -u)" | tee "${{ github.workspace }}/${{ env.DOCKER_CONTEXT_PATH }}/sdk/VERSION"
- name: Build Docker Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
env:
SOURCE_DATE_EPOCH: ${{ steps.commit.outputs.source-date }}
if: ${{ steps.baseline.outputs.exists == 'false' && !failure() && !cancelled() }}
Expand Down Expand Up @@ -444,7 +444,7 @@ jobs:
run: docker info

- name: Build Docker Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
env:
SOURCE_DATE_EPOCH: ${{ needs.generate-baseline.outputs.source-date }}
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
import com.swirlds.platform.system.SwirldMain;
import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.system.events.Event;
import com.swirlds.platform.system.state.notifications.AsyncFatalIssListener;
import com.swirlds.platform.system.state.notifications.StateHashedListener;
import com.swirlds.platform.system.status.PlatformStatus;
import com.swirlds.platform.system.transaction.Transaction;
Expand Down Expand Up @@ -1003,6 +1004,7 @@ private void initializeDagger(@NonNull final State state, @NonNull final InitTri
notifications.unregister(PlatformStatusChangeListener.class, this);
notifications.unregister(ReconnectCompleteListener.class, daggerApp.reconnectListener());
notifications.unregister(StateWriteToDiskCompleteListener.class, daggerApp.stateWriteToDiskListener());
notifications.unregister(AsyncFatalIssListener.class, daggerApp.fatalIssListener());
if (blockStreamEnabled) {
notifications.unregister(StateHashedListener.class, daggerApp.blockStreamManager());
}
Expand Down Expand Up @@ -1056,6 +1058,7 @@ private void initializeDagger(@NonNull final State state, @NonNull final InitTri
notifications.register(PlatformStatusChangeListener.class, this);
notifications.register(ReconnectCompleteListener.class, daggerApp.reconnectListener());
notifications.register(StateWriteToDiskCompleteListener.class, daggerApp.stateWriteToDiskListener());
notifications.register(AsyncFatalIssListener.class, daggerApp.fatalIssListener());
if (blockStreamEnabled) {
notifications.register(StateHashedListener.class, daggerApp.blockStreamManager());
daggerApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import com.swirlds.platform.listeners.StateWriteToDiskCompleteListener;
import com.swirlds.platform.system.InitTrigger;
import com.swirlds.platform.system.Platform;
import com.swirlds.platform.system.state.notifications.AsyncFatalIssListener;
import com.swirlds.state.State;
import com.swirlds.state.lifecycle.StartupNetworks;
import com.swirlds.state.lifecycle.info.NetworkInfo;
Expand Down Expand Up @@ -146,6 +147,8 @@ public interface HederaInjectionComponent {

SubmissionManager submissionManager();

AsyncFatalIssListener fatalIssListener();

@Component.Builder
interface Builder {
@BindsInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ public static void main(final String... args) throws Exception {
EXCEPTION.getMarker(),
"Multiple nodes were supplied via the command line. Only one node can be started per java process.");
exitSystem(NODE_ADDRESS_MISMATCH);
// the following throw is not reachable in production,
// but reachable in testing with static mocked system exit calls.
throw new ConfigurationException();
}
final var platformConfig = buildPlatformConfig();
// Determine which nodes were _requested_ to run from the command line
Expand Down Expand Up @@ -410,12 +413,18 @@ private static NodeId ensureSingleNode(@NonNull final List<NodeId> nodesToRun) {
if (nodesToRun.isEmpty()) {
final String errorMessage = "No nodes are configured to run locally.";
logger.error(STARTUP.getMarker(), errorMessage);
exitSystem(NODE_ADDRESS_MISMATCH, errorMessage);
// the following throw is not reachable in production,
// but reachable in testing with static mocked system exit calls.
throw new ConfigurationException(errorMessage);
}

if (nodesToRun.size() > 1) {
final String errorMessage = "Multiple nodes are configured to run locally.";
logger.error(EXCEPTION.getMarker(), errorMessage);
exitSystem(NODE_ADDRESS_MISMATCH, errorMessage);
// the following throw is not reachable in production,
// but reachable in testing with static mocked system exit calls.
throw new ConfigurationException(errorMessage);
}
return nodesToRun.getFirst();
Expand All @@ -437,6 +446,8 @@ private static AddressBook loadAddressBook(@NonNull final String addressBookPath
} catch (final Exception e) {
logger.error(EXCEPTION.getMarker(), "Error loading address book", e);
exitSystem(CONFIGURATION_ERROR);
// the following throw is not reachable in production,
// but reachable in testing with static mocked system exit calls.
throw e;
}
}
Expand Down
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 All @@ -17,12 +17,14 @@
package com.hedera.node.app.platform;

import com.hedera.node.app.annotations.CommonExecutor;
import com.hedera.node.app.state.listeners.FatalIssListenerImpl;
import com.hedera.node.app.state.listeners.ReconnectListener;
import com.hedera.node.app.state.listeners.WriteStateToDiskListener;
import com.swirlds.common.stream.Signer;
import com.swirlds.platform.listeners.ReconnectCompleteListener;
import com.swirlds.platform.listeners.StateWriteToDiskCompleteListener;
import com.swirlds.platform.system.Platform;
import com.swirlds.platform.system.state.notifications.AsyncFatalIssListener;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
Expand Down Expand Up @@ -68,4 +70,8 @@ static IntSupplier provideFrontendThrottleSplit(@NonNull final Platform platform
@Binds
@Singleton
StateWriteToDiskCompleteListener bindStateWrittenToDiskListener(WriteStateToDiskListener writeStateToDiskListener);

@Binds
@Singleton
AsyncFatalIssListener bindFatalIssListener(FatalIssListenerImpl listener);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.AsyncFatalIssListener;
import com.swirlds.platform.system.state.notifications.IssNotification;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Singleton
public class FatalIssListenerImpl implements AsyncFatalIssListener {

private static final Logger log = LogManager.getLogger(FatalIssListenerImpl.class);

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

@Override
public void notify(@NonNull final IssNotification data) {
log.warn("ISS detected (type={}, round={})", data.getIssType(), data.getRound());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright (C) 2021-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;

import static com.swirlds.platform.system.SystemExitCode.NODE_ADDRESS_MISMATCH;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mock.Strictness.LENIENT;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;

import com.hedera.hapi.node.base.SemanticVersion;
import com.hedera.node.app.version.ServicesSoftwareVersion;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.platform.config.legacy.ConfigurationException;
import com.swirlds.platform.config.legacy.LegacyConfigProperties;
import com.swirlds.platform.config.legacy.LegacyConfigPropertiesLoader;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.system.SystemExitUtils;
import com.swirlds.platform.system.address.AddressBook;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
final class ServicesMainTest {
private static final MockedStatic<LegacyConfigPropertiesLoader> legacyConfigPropertiesLoaderMockedStatic =
mockStatic(LegacyConfigPropertiesLoader.class);

@Mock(strictness = LENIENT)
private LegacyConfigProperties legacyConfigProperties = mock(LegacyConfigProperties.class);

@Mock(strictness = LENIENT)
private Metrics metrics;

@Mock(strictness = LENIENT)
private Hedera hedera;

@Mock
private PlatformMerkleStateRoot merkleStateRoot;

private final ServicesMain subject = new ServicesMain();

@AfterAll
static void afterAll() {
legacyConfigPropertiesLoaderMockedStatic.close();
}

// no local nodes specified, no environment nodes specified
@Test
void throwsExceptionOnNoNodesToRun() {
withBadCommandLineArgs();
String[] args = {};
try (MockedStatic<SystemExitUtils> systemExitUtilsMockedStatic = mockStatic(SystemExitUtils.class)) {
assertThatThrownBy(() -> ServicesMain.main(args)).isInstanceOf(ConfigurationException.class);
systemExitUtilsMockedStatic.verify(
() -> SystemExitUtils.exitSystem(eq(NODE_ADDRESS_MISMATCH), anyString()));
}
}

// local node specified which does not match the address book
@Test
void hardExitOnNonMatchingNodeId() {
withBadCommandLineArgs();
String[] args = {"-local", "1234"}; // 1234 does not match anything in address book

try (MockedStatic<SystemExitUtils> systemExitUtilsMockedStatic = mockStatic(SystemExitUtils.class)) {
assertThatThrownBy(() -> ServicesMain.main(args)).isInstanceOf(ConfigurationException.class);
systemExitUtilsMockedStatic.verify(
() -> SystemExitUtils.exitSystem(eq(NODE_ADDRESS_MISMATCH), anyString()));
}
}

// more than one local node specified on the commandline
@Test
void hardExitOnTooManyCliNodes() {
withBadCommandLineArgs();
String[] args = {"-local", "1", "2"}; // both "1" and "2" match entries in address book

try (MockedStatic<SystemExitUtils> systemExitUtilsMockedStatic = mockStatic(SystemExitUtils.class)) {
assertThatThrownBy(() -> ServicesMain.main(args)).isInstanceOf(ConfigurationException.class);
systemExitUtilsMockedStatic.verify(() -> SystemExitUtils.exitSystem(NODE_ADDRESS_MISMATCH));
}
}

@Test
void delegatesSoftwareVersion() {
ServicesMain.initGlobal(hedera, metrics);
final var mockVersion = new ServicesSoftwareVersion(SemanticVersion.DEFAULT);
given(hedera.getSoftwareVersion()).willReturn(mockVersion);
assertSame(mockVersion, subject.getSoftwareVersion());
}

@Test
void noopsAsExpected() {
ServicesMain.initGlobal(hedera, metrics);
assertDoesNotThrow(subject::run);
}

@Test
void createsNewMerkleStateRoot() {
ServicesMain.initGlobal(hedera, metrics);
given(hedera.newMerkleStateRoot()).willReturn(merkleStateRoot);
assertSame(merkleStateRoot, subject.newMerkleStateRoot());
}

private void withBadCommandLineArgs() {
legacyConfigPropertiesLoaderMockedStatic
.when(() -> LegacyConfigPropertiesLoader.loadConfigFile(any()))
.thenReturn(legacyConfigProperties);

when(legacyConfigProperties.getAddressBook()).thenReturn(new AddressBook());
}
}
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 @@ -83,6 +83,11 @@ public record ContractsConfig(
@ConfigProperty(value = "systemContract.scheduleService.signSchedule.enabled", defaultValue = "true")
@NetworkProperty
boolean systemContractSignScheduleEnabled,
@ConfigProperty(
value = "systemContract.scheduleService.signSchedule.from.contract.enabled",
defaultValue = "true")
@NetworkProperty
boolean systemContractSignScheduleFromContractEnabled,
@ConfigProperty(value = "systemContract.scheduleService.authorizeSchedule.enabled", defaultValue = "true")
@NetworkProperty
boolean systemContractAuthorizeScheduleEnabled,
Expand Down
Loading

0 comments on commit 1c690c3

Please sign in to comment.