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: add support for attach jvm debugger #549

Merged
merged 27 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,55 @@ You can find log for running solo command under the directory `~/.solo/logs/`
The file `solo.log` contains the logs for the solo command.
The file `hashgraph-sdk.log` contains the logs from solo client when sending transactions to network nodes.

## Using Intellj remote debug with solo

JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved
Example 1: attach jvm debugger to a hedera node
```bash
./test/e2e/setup-e2e.sh
solo network deploy -i node1,node2,node3 --debug-nodeid node2
solo node keys --gossip-keys --tls-keys
JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
solo node start -i node1,node2,node3 --debug-nodeid node2
```

Once you see the following message, you can launch jvm debugger from Intellij
```
❯ Check all nodes are ACTIVE
Check node: node1,
Check node: node3, Please attach JVM debugger now.
Check node: node4,
```

Example 2: attach jvm debugger with node add operation

```bash
./test/e2e/setup-e2e.sh
solo network deploy -i node1,node2,node3 --pvcs
solo node keys --gossip-keys --tls-keys
JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
solo node start -i node1,node2,node3
solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data
```

Example 3: attach jvm debugger with node update operation
```bash
./test/e2e/setup-e2e.sh
solo network deploy -i node1,node2,node3
solo node keys --gossip-keys --tls-keys
JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
solo node start -i node1,node2,node3
solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem
```

Example 4: attach jvm debugger with node delete operation
```bash
./test/e2e/setup-e2e.sh
solo network deploy -i node1,node2,node3,node4
solo node keys --gossip-keys --tls-keys
JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved
solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data
solo node start -i node1,node2,node3,node4
solo node delete --node-id node2 --debug-nodeid node3
```

## Support

Expand Down
12 changes: 12 additions & 0 deletions src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,17 @@ export const persistentVolumeClaims = {
}
}

/** @type {CommandFlag} **/
export const debugNodeId = {
constName: 'debugNodeId',
name: 'debug-nodeid',
definition: {
describe: 'Enable default jvm debug port (5005) for the given node id',
defaultValue: '',
type: 'string'
}
}

/** @type {CommandFlag[]} **/
export const allFlags = [
accountId,
Expand Down Expand Up @@ -785,6 +796,7 @@ export const allFlags = [
grpcEndpoints,
hederaExplorerTlsHostName,
hederaExplorerTlsLoadBalancerIp,
debugNodeId,
localBuildPath,
log4j2Xml,
namespace,
Expand Down
15 changes: 14 additions & 1 deletion src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { constants, Templates } from '../core/index.mjs'
import * as prompts from './prompts.mjs'
import * as helpers from '../core/helpers.mjs'
import path from 'path'
import { validatePath } from '../core/helpers.mjs'
import { addDebugOptions, validatePath } from '../core/helpers.mjs'
import fs from 'fs'

export class NetworkCommand extends BaseCommand {
Expand Down Expand Up @@ -74,6 +74,7 @@ export class NetworkCommand extends BaseCommand {
flags.fstChartVersion,
flags.hederaExplorerTlsHostName,
flags.hederaExplorerTlsLoadBalancerIp,
flags.debugNodeId,
flags.log4j2Xml,
flags.namespace,
flags.nodeIDs,
Expand Down Expand Up @@ -138,6 +139,17 @@ export class NetworkCommand extends BaseCommand {
valuesArg += this.prepareValuesFiles(config.valuesFile)
}

if (config.app !== constants.HEDERA_APP_NAME) {
const index = config.nodeIds.length
for (let i = 0; i < index; i++) {
valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].name=JAVA_MAIN_CLASS"`
valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].value=com.swirlds.platform.Browser"`
}
valuesArg = addDebugOptions(valuesArg, config.debugNodeId, 1)
} else {
valuesArg = addDebugOptions(valuesArg, config.debugNodeId)
}

const profileName = this.configManager.getFlag(flags.profileName)
this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName)
if (this.profileValuesFile) {
Expand Down Expand Up @@ -182,6 +194,7 @@ export class NetworkCommand extends BaseCommand {
flags.bootstrapProperties,
flags.cacheDir,
flags.chainId,
flags.debugNodeId,
flags.deployHederaExplorer,
flags.deployMirrorNode,
flags.hederaExplorerTlsLoadBalancerIp,
Expand Down
Loading
Loading