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

startup_regtest: configure clnrest and generate rune #6860

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

endothermicdev
Copy link
Collaborator

This configures the startup_regtest.sh nodes to enable clnrest + websocket while also providing output on their connection info (an unrestricted rune is generated as well.) Also uses the snap installed bitcoind path if appropriate.

Format of the start_ln output is:
Commands:
l1-cli, l1-log,
l2-cli, l2-log,
bt-cli, stop_ln, fund_nodes
Node Info:
l1 rest: https://127.0.0.1:3110 rune: "lgkWSp0PQK-pkbElLpjcNVQnX7yfEjouJaJHjLuW8w89OA=="
l2 rest: https://127.0.0.1:3111 rune: "sUqGqkevGYG2r1e_JUiz8Me00GhtTv5-IuGk4o9Beyc9OQ=="

Changelog-None

@endothermicdev
Copy link
Collaborator Author

rebased on #6857 and should now check if clnrest is running before generating runes and providing connection urls.

@ShahanaFarooqui
Copy link
Collaborator

lgtm.

The only issue I found is that it generates a new rune each time we start the node. Even if the node already has a rune. We can use showrunes to get the already generated rune but it looks an overkill for the script as it is just for developer testing and runs in /tmp.

Copy link
Collaborator

@ShahanaFarooqui ShahanaFarooqui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1dfccbb

@tonyaldon
Copy link
Contributor

I just tried to run start_ln with the new changes.

Everything works well with clnrest python dependencies installed but not without the dependencies:

$ start_ln
Bitcoin Core starting
awaiting bitcoind...
Making "default" bitcoind wallet.
[1] 665564
lightningd: Config file /tmp/l1-regtest/config line 6: clnrest-port=3110: unknown option
[1]+  Exit 1                  test -f "/tmp/l$i-$network/lightningd-$network.pid" || $EATMYDATA "$LIGHTNINGD" "--network=$network" "--lightning-dir=/tmp/l$i-$network" "--bitcoin-datadir=$PATH_TO_BITCOIN" "--database-upgrade=true"
[1] 665603
WARNING: eatmydata not found: install it for faster testing
Commands:
        l1-cli, l1-log,
        l2-cli, l2-log,
        bt-cli, stop_ln, fund_nodes
lightningd: Config file /tmp/l2-regtest/config line 6: clnrest-port=3111: unknown option
[1]+  Exit 1                  test -f "/tmp/l$i-$network/lightningd-$network.pid" || $EATMYDATA "$LIGHTNINGD" "--network=$network" "--lightning-dir=/tmp/l$i-$network" "--bitcoin-datadir=$PATH_TO_BITCOIN" "--database-upgrade=true"
grep: /tmp/l5-regtest/log: No such file or directory
grep: /tmp/l5-regtest/log: No such file or directory
timed out parsing log /tmp/l5-regtest/log

In that second case, it seems that the node doesn't start because after disabling clnrest the option clnrest-port is not defined but present in the config file:

lightningd: Config file /tmp/l1-regtest/config line 6: clnrest-port=3110: unknown option

@endothermicdev
Copy link
Collaborator Author

That makes sense. I've updated it to test if clnrest loads before writing the config file. If any dependencies are missing I would expect it to fail there and we can just skip it. I'll squash these commits if this solution works for you.

@tonyaldon
Copy link
Contributor

Now it also works without clnrest dependencies.

But depending on how long it takes for the last node to be running, I got this message in the terminal:

grep: /tmp/l3-regtest/log: No such file or directory
grep: /tmp/l3-regtest/log: No such file or directory

This is due to the following call to clnrest_status in start_ln

wait_for_lightningd "$nodes"
active_status=$(clnrest_status "/tmp/$i-$network/log")

using $i variable set at the end of the for loop in wait_for_lightningd.

If I understand correctly, what you want to do in wait_for_lightningd is to test that the last started node is running. If this the case, I think you can remove wait_for_lightningd and use this patch in start_ln instead:

-	wait_for_lightningd "$nodes"
-	active_status=$(clnrest_status "/tmp/l$i-$network/log")
+	while ! $LCLI --lightning-dir=/tmp/l"$nodes"-"$network" getinfo > /tmp/null 2>&1; do sleep 1; done
+	active_status=$(clnrest_status "/tmp/l$nodes-$network/log")

This allows use of clnrest + websocket in the regtest environment.
If clnrest starts up, a rune is generated and provided along with
the connection info.

Also uses the snap installed bitcoind path if appropriate.

Format of the start_ln output is:
Commands:
	l1-cli, l1-log,
	l2-cli, l2-log,
	bt-cli, stop_ln, fund_nodes
Node Info:
	l1 rest: https://127.0.0.1:3110  rune: "lgkWSp0PQK-pkbElLpjcNVQnX7yfEjouJaJHjLuW8w89OA=="
	l2 rest: https://127.0.0.1:3111  rune: "sUqGqkevGYG2r1e_JUiz8Me00GhtTv5-IuGk4o9Beyc9OQ=="

Changelog-None
@niftynei
Copy link
Collaborator

niftynei commented Dec 5, 2023

Rebased on latest; addressed last comment from @tonyaldon re: index for $i being out of scope/wrong.

ACK 714de43

@niftynei niftynei merged commit 9585b7c into ElementsProject:master Dec 6, 2023
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants