Skip to content

Commit

Permalink
feat: for v0.59.x or greater set the internal IP address to 127.0.0.1…
Browse files Browse the repository at this point in the history
… to avoid an ISS, in config.txt (#1162)

Signed-off-by: instamenta <[email protected]>
Signed-off-by: Jeromy Cannon <[email protected]>
Signed-off-by: Alex Kuzmin <[email protected]>
Co-authored-by: Jeromy Cannon <[email protected]>
Co-authored-by: Alex Kuzmin <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2025
1 parent af3ae29 commit 4ca488b
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/flow-task-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:

- name: Run Example Task File Test with type ${{ matrix.type }}
run: |
export CONSENSUS_NODE_VERSION=v0.58.3
task default
.github/workflows/script/solo_smoke_test.sh ${{ matrix.type }}
task clean
2 changes: 1 addition & 1 deletion .github/workflows/zxc-e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
if: ${{ runner.os == 'linux' && (inputs.npm-test-script == 'test-e2e-node-local-hedera' || inputs.npm-test-script == 'test-e2e-node-local-ptt' || inputs.npm-test-script == 'test-e2e-node-add-local') && !cancelled() && !failure() }}
run: |
cd ..
git clone https://github.com/hashgraph/hedera-services.git --depth 1 --branch v0.58.1
git clone https://github.com/hashgraph/hedera-services.git --depth 1 --branch v0.58.3
cd hedera-services
ls -ltr
${{ env.CG_EXEC }} ./gradlew assemble --stacktrace --info
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ tasks:
cmds:
- |
if [[ "${CONSENSUS_NODE_VERSION}" != "" ]]; then
export CONSENSUS_NODE_FLAG='--release-tag ${CONSENSUS_NODE_VERSION}'
export CONSENSUS_NODE_FLAG='--release-tag {{.CONSENSUS_NODE_VERSION}}'
fi
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node setup --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${CONSENSUS_NODE_FLAG} ${LOCAL_BUILD_FLAG} -q --dev
Expand Down
2 changes: 1 addition & 1 deletion examples/performance-tuning/latitude/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vars:
env:
SOLO_NETWORK_SIZE: 10
SOLO_NAMESPACE: %SOLO_NAMESPACE%
SOLO_CHART_VERSION: 0.42.3
SOLO_CHART_VERSION: 0.42.10
#CONSENSUS_NODE_VERSION: 0.0.0
VALUES_FLAG: "--values-file {{.USER_WORKING_DIR}}/init-containers-values.yaml"
SETTINGS_FLAG: "--settings-txt {{.USER_WORKING_DIR}}/settings.txt"
Expand Down
2 changes: 2 additions & 0 deletions examples/performance-tuning/latitude/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
contracts.chainId=298
entities.unlimitedAutoAssociationsEnabled=true
bootstrap.throttleJsonDef.resource=genesis/throttles-dev.json
networkAdmin.exportCandidateRoster=true
addressBook.useRosterLifecycle=true
Empty file.
2 changes: 2 additions & 0 deletions resources/templates/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ blockStream.streamMode=RECORDS
scheduling.longTermEnabled=false
# TODO: uncomment this when we are ready to use genesis-network.json
#addressBook.useRosterLifecycle=true
# TODO: we can remove this after we no longer need less than v0.59.x
networkAdmin.exportCandidateRoster=true
7 changes: 5 additions & 2 deletions src/commands/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,10 @@ export class Flags {
constName: 'applicationEnv',
name: 'application-env',
definition: {
describe: 'application.env file for node',
defaultValue: '',
describe:
'the application.env file for the node provides environment variables to the solo-container' +
' to be used when the hedera platform is started',
defaultValue: path.join(constants.SOLO_CACHE_DIR, 'templates', 'application.env'),
type: 'string',
},
prompt: undefined,
Expand Down Expand Up @@ -1838,6 +1840,7 @@ export class Flags {
static readonly nodeConfigFileFlags = new Map(
[
Flags.apiPermissionProperties,
Flags.applicationEnv,
Flags.applicationProperties,
Flags.bootstrapProperties,
Flags.log4j2Xml,
Expand Down
43 changes: 33 additions & 10 deletions src/core/profile_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type {AnyObject, DirPath, NodeAlias, NodeAliases, Path} from '../types/al
import type {Optional} from '../types/index.js';
import {inject, injectable} from 'tsyringe-neo';
import {patchInject} from './container_helper.js';
import {HEDERA_PLATFORM_VERSION} from '../../version.js';
import * as versions from '../../version.js';

@injectable()
export class ProfileManager {
Expand Down Expand Up @@ -254,13 +254,11 @@ export class ProfileManager {
yamlRoot,
);

if (this.configManager.getFlag(flags.applicationEnv)) {
this._setFileContentsAsValue(
'hedera.configMaps.applicationEnv',
this.configManager.getFlag(flags.applicationEnv),
yamlRoot,
);
}
this._setFileContentsAsValue(
'hedera.configMaps.applicationEnv',
path.join(stagingDir, 'templates', 'application.env'),
yamlRoot,
);

if (profile.consensus) {
// set default for consensus pod
Expand Down Expand Up @@ -473,7 +471,7 @@ export class ProfileManager {
throw new MissingArgumentError('nodeAccountMap the map of node IDs to account IDs is required');
}

if (!releaseTag) releaseTag = HEDERA_PLATFORM_VERSION;
if (!releaseTag) releaseTag = versions.HEDERA_PLATFORM_VERSION;

if (!fs.existsSync(destPath)) {
throw new IllegalArgumentError(`config destPath does not exist: ${destPath}`, destPath);
Expand All @@ -494,7 +492,32 @@ export class ProfileManager {

let nodeSeq = 0;
for (const nodeAlias of nodeAccountMap.keys()) {
const internalIP = Templates.renderFullyQualifiedNetworkPodName(namespace, nodeAlias);
let internalIP: string;

//? Explanation: for v0.59.x the internal IP address is set to 127.0.0.1 to avoid an ISS

// for versions that satisfy 0.59.x
if (semver.satisfies(releaseVersion, '^0.59.0', {includePrerelease: true})) {
internalIP = '127.0.0.1';
}

// versions less than 0.59.0
else if (
semver.lt(
releaseVersion,
'0.59.0',
// @ts-expect-error TS2353: Object literal may only specify known properties
{includePrerelease: true},
)
) {
internalIP = Templates.renderFullyQualifiedNetworkPodName(namespace, nodeAlias);
}

// versions greater than 0.59.0
else {
internalIP = '127.0.0.1';
}

const externalIP = Templates.renderFullyQualifiedNetworkSvcName(namespace, nodeAlias);
const account = nodeAccountMap.get(nodeAlias);

Expand Down
2 changes: 2 additions & 0 deletions test/e2e/commands/node_local_hedera.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {Duration} from '../../../src/core/time/duration.js';
import {type NodeCommand} from '../../../src/commands/node/index.js';
import {type AccountCommand} from '../../../src/commands/account.js';
import {type AccountManager} from '../../../src/core/account_manager.js';
import {LOCAL_HEDERA_PLATFORM_VERSION} from '../../../version.js';

const LOCAL_HEDERA = 'local-hedera-app';
const argv = getDefaultArgv();
Expand All @@ -43,6 +44,7 @@ let hederaK8: K8;
console.log('Starting local build for Hedera app');
argv[flags.localBuildPath.name] = 'node1=../hedera-services/hedera-node/data/,../hedera-services/hedera-node/data';
argv[flags.namespace.name] = LOCAL_HEDERA;
argv[flags.releaseTag.name] = LOCAL_HEDERA_PLATFORM_VERSION;

e2eTestSuite(
LOCAL_HEDERA,
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/commands/node_local_ptt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {Flags as flags} from '../../../src/commands/flags.js';
import {e2eTestSuite, getDefaultArgv, TEST_CLUSTER} from '../../test_util.js';
import {Duration} from '../../../src/core/time/duration.js';
import {type K8} from '../../../src/core/k8.js';
import {LOCAL_HEDERA_PLATFORM_VERSION} from '../../../version.js';

const LOCAL_PTT = 'local-ptt-app';
const argv = getDefaultArgv();
Expand All @@ -37,6 +38,7 @@ argv[flags.app.name] = 'PlatformTestingTool.jar';
argv[flags.appConfig.name] =
'../hedera-services/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/resources/FCMFCQ-Basic-2.5k-5m.json';
argv[flags.namespace.name] = LOCAL_PTT;
argv[flags.releaseTag.name] = LOCAL_HEDERA_PLATFORM_VERSION;

e2eTestSuite(LOCAL_PTT, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, bootstrapResp => {
describe('Node for platform app should start successfully', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/test_add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import * as NodeCommandConfigs from '../src/commands/node/configs.js';
import type {NodeAlias} from '../src/types/aliases.js';
import type {NetworkNodeServices} from '../src/core/network_node_services.js';
import {Duration} from '../src/core/time/duration.js';
import {LOCAL_HEDERA_PLATFORM_VERSION} from '../version.js';

const defaultTimeout = Duration.ofMinutes(2).toMillis();

Expand All @@ -48,7 +49,8 @@ export function testNodeAdd(
argv[flags.generateTlsKeys.name] = true;
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined;
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG;
argv[flags.releaseTag.name] =
!localBuildPath || localBuildPath === '' ? HEDERA_PLATFORM_VERSION_TAG : LOCAL_HEDERA_PLATFORM_VERSION;
argv[flags.namespace.name] = namespace;
argv[flags.force.name] = true;
argv[flags.persistentVolumeClaims.name] = true;
Expand Down
14 changes: 13 additions & 1 deletion test/unit/core/profile_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ import * as version from '../../../version.js';
import type {NodeAlias} from '../../../src/types/aliases.js';
import {container} from 'tsyringe-neo';
import {resetTestContainer} from '../../test_container.js';
import {Templates} from '../../../src/core/templates.js';

describe('ProfileManager', () => {
let tmpDir: string, configManager: ConfigManager, profileManager: ProfileManager, cacheDir: string;

const testProfileFile = path.join('test', 'data', 'test-profiles.yaml');
let stagingDir = '';

before(() => {
resetTestContainer();
Expand All @@ -45,10 +47,18 @@ describe('ProfileManager', () => {
configManager.setFlag(flags.releaseTag, version.HEDERA_PLATFORM_VERSION);
cacheDir = configManager.getFlag<string>(flags.cacheDir) as string;
configManager.setFlag(flags.apiPermissionProperties, path.join(cacheDir, 'templates', 'api-permission.properties'));
configManager.setFlag(flags.applicationEnv, path.join(cacheDir, 'templates', 'application.env'));
configManager.setFlag(flags.applicationProperties, path.join(cacheDir, 'templates', 'application.properties'));
configManager.setFlag(flags.bootstrapProperties, path.join(cacheDir, 'templates', 'bootstrap.properties'));
configManager.setFlag(flags.log4j2Xml, path.join(cacheDir, 'templates', 'log4j2.xml'));
configManager.setFlag(flags.settingTxt, path.join(cacheDir, 'templates', 'settings.txt'));
stagingDir = Templates.renderStagingDir(
configManager.getFlag(flags.cacheDir),
configManager.getFlag(flags.releaseTag),
);
if (!fs.existsSync(stagingDir)) {
fs.mkdirSync(stagingDir, {recursive: true});
}
});

after(() => {
Expand Down Expand Up @@ -130,10 +140,12 @@ describe('ProfileManager', () => {
configManager.setFlag(flags.profileFile, testProfileFile);

// profileManager.loadProfiles(true)
const file = path.join(tmpDir, '_setFileContentsAsValue.txt');
const file = path.join(tmpDir, 'application.env');
const fileContents = '# row 1\n# row 2\n# row 3';
fs.writeFileSync(file, fileContents);
configManager.setFlag(flags.applicationEnv, file);
const destFile = path.join(stagingDir, 'templates', 'application.env');
fs.cpSync(file, destFile, {force: true});
const cachedValuesFile = await profileManager.prepareValuesForSoloChart('test');
const valuesYaml: any = yaml.parse(fs.readFileSync(cachedValuesFile).toString());
expect(valuesYaml.hedera.configMaps.applicationEnv).to.equal(fileContents);
Expand Down
5 changes: 3 additions & 2 deletions version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/

export const HELM_VERSION = 'v3.14.2';
export const SOLO_CHART_VERSION = '0.42.4';
export const HEDERA_PLATFORM_VERSION = 'v0.58.3';
export const SOLO_CHART_VERSION = '0.42.10';
export const HEDERA_PLATFORM_VERSION = 'v0.59.0-main.x5322bdc';
export const LOCAL_HEDERA_PLATFORM_VERSION = 'v0.58.3';
export const MIRROR_NODE_VERSION = '0.120.1';
export const HEDERA_EXPLORER_VERSION = '0.2.1';
export const HEDERA_JSON_RPC_RELAY_VERSION = 'v0.63.2';

0 comments on commit 4ca488b

Please sign in to comment.