joelklabo / nostr-control

A CLN Plugin you can interact with over Nostr DM
20 stars 4 forks source link

Help with starting on Raspiblitz #6

Open openoms opened 1 year ago

openoms commented 1 year ago

Hi Joelklabo, great project!

Tried to run on a Raspiblitz with CLN v23.02.2

Steps taken:

sudo su - bitcoin
cd /home/bitcoin/cl-plugins-available/
git clone https://github.com/joelklabo/nostr-control
# filled in the config.json
chmod +x /home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js
lightning-cli plugin start /home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js

# same when using in the config file:
plugin=/home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js

Results in:

{
   "code": -3,
   "message": "/home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js: exited before replying to getmanifest"
}

and in sudo journalctl -fu lightning

May 05 16:13:40 raspberrypi systemd[1]: Started c-lightning daemon on mainnet.
May 05 16:13:48 raspberrypi sh[2021513]: <--- Last few GCs --->
May 05 16:13:48 raspberrypi sh[2021513]: <--- JS stacktrace --->
May 05 16:13:48 raspberrypi sh[2021513]: #
May 05 16:13:48 raspberrypi sh[2021513]: # Fatal javascript OOM in MemoryChunk allocation failed during deserialization.
May 05 16:13:48 raspberrypi sh[2021513]: #

Are there steps I am missing? I presume dependencies would need to be installed, but npm install does not work as noted in the readme.

joelklabo commented 1 year ago

Hey @openoms! Let me go through the process again and see what I'm missing.

joelklabo commented 1 year ago

@openoms do you have node installed? I just ran into the same thing on a new VM but realized node wasn't installed. Could that be it?

openoms commented 1 year ago

@openoms do you have node installed? I just ran into the same thing on a new VM but realized node wasn't installed. Could that be it?

Checked that one first. Node and npm are installed system-wide:

bitcoin@raspberrypi:~/cl-plugins-available/nostr-control $ node --version
v18.12.0
$ which node
/usr/bin/node
$ npm --version
8.19.2
$ which npm
/usr/bin/npm

How about the cl conf settings? Mine are:

alias=xxxx
base=0
fee-per-satoshi=xx
min-capacity-sat=500000

network=bitcoin
log-file=cl.log
log-level=info
plugin-dir=/home/bitcoin/cl-plugins-enabled

# Tor settings
proxy=127.0.0.1:9050
bind-addr=127.0.0.1:9736
addr=statictor:127.0.0.1:9051/torport=9736

always-use-proxy=true
bind-addr=0.0.0.0:9735

rpc-file-mode=0660

feeadjuster-imbalance=xx
feeadjuster-threshold=xx
feeadjuster-threshold-abs=xx
feeadjuster-enough-liquidity=xxxx
feeadjuster-adjustment-method=hard

grpc-port=4772
joelklabo commented 1 year ago

Yeah, that all seems correct. The plugin actually gets it's settings from config.json in it's directory so I can updated them while the plugin in running. But you mentioned that you had filled that in. Mind sharing what that looks like? (with redacted keys)

Also, if it made any progress in launching there should be a debug.log in that directory that might have some information in it.

Could you confirm what commit your working from also just to make sure?

I need to add some versioning and some more logging it sounds like. I should probably also redirect the logging to the main cln log as well. It was helpful to have my own for development but probably not for your situation.

joelklabo commented 1 year ago

@openoms let me know if I can help debug this anymore. I'd be really excited to see it available on raspiblitz!

openoms commented 1 year ago

Had played around trying different config settings eg tried eith and without wss:// in the relay address, but coming to the same. My redacted config:

{
  relay: "nostr.zebedee.cloud",
  bot_secret: "hex-priv-key",
  your_pubkey: "hex-pub-key",
  verbosity: "verbose",
  show_failed_forwards: true
}
joelklabo commented 1 year ago

I've recently added a bunch more logging, might find some clues if you update to master. All the dependencies are checked in in node_modules/. Could you have run npm install I think you said not but just double checking.

frbitten commented 1 year ago

I'm having exactly the same problem. I didn't run "npm install" and I have the latest master version. The debug.log file was not generated.

Aug 27 00:52:43 freedom-server systemd[1]: Starting C-Lightning daemon... Aug 27 00:52:43 freedom-server lightningd[2833861]: <--- Last few GCs ---> Aug 27 00:52:43 freedom-server lightningd[2833861]: <--- JS stacktrace ---> Aug 27 00:52:43 freedom-server lightningd[2833861]: # Aug 27 00:52:43 freedom-server lightningd[2833861]: # Fatal javascript OOM in MemoryChunk allocation failed during deserialization. Aug 27 00:52:43 freedom-server lightningd[2833861]: # Aug 27 00:53:56 freedom-server systemd[1]: Started C-Lightning daemon.

If I try to run it manually I get this error:

            throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
                  ^
Error: private key must be 32 bytes, hex or bigint, not string
    at Object.normPrivateKeyToScalar (file:///hdd/cln/.lightning/plugins/nostr-control/node_modules/@noble/curves/esm/abstract/weierstrass.js:158:19)
    at schnorrGetExtPubKey (file:///hdd/cln/.lightning/plugins/nostr-control/node_modules/@noble/curves/esm/secp256k1.js:110:30)
    at Object.schnorrGetPublicKey [as getPublicKey] (file:///hdd/cln/.lightning/plugins/nostr-control/node_modules/@noble/curves/esm/secp256k1.js:141:12)
    at getPublicKey (file:///hdd/cln/.lightning/plugins/nostr-control/node_modules/nostr-tools/lib/esm/nostr.mjs:14:29)
    at new NostrDMBot (file:///hdd/cln/.lightning/plugins/nostr-control/node_modules/nostr-dm-bot/nostr-dm-bot.js:11:21)
    at file:///hdd/cln/.lightning/plugins/nostr-control/nostr-control.js:53:13
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async loadESM (node:internal/process/esm_loader:91:5)

Node.js v18.7.0

use key in standard nostr format starting with nsec

frbitten commented 1 year ago

I used https://nostrtool.com/ to convert to HEX format and it worked when calling nostr-control from the command line. But when starting the CLN it continues with the first reported error.

openoms commented 1 month ago

Still couldn't start it on amd64 using CLN v24.08 and node --version v20.5.1

After just cloning the repo and restarting CLN with the line in the config:

plugin=/home/bitcoin/cl-plugins-enabled/nostr-control/nostr-control.js

getting the error:

Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: #
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: # Fatal error in , line 0
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: # Check failed: 12 == (*__errno_location ()).
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: #
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: #
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: #
Sep 14 19:47:39 raspiblitz-amd64 sh[1716626]: #FailureMessage Object: 0x7ffd111b31c0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  1: 0xd12431  [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  2: 0x20ec041 V8_Fatal(char const*, ...) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  3: 0x20f6e67 v8::base::OS::SetPermissions(void*, unsigned long, v8::base::OS::MemoryPermission) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  4: 0x113548a v8::internal::MemoryAllocator::SetPermissionsOnExecutableMemoryChunk(v8::internal::VirtualMemory*, unsigned long, unsigned long, unsigned long) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  5: 0x113573e v8::internal::MemoryAllocator::AllocateAlignedMemory(unsigned long, unsigned long, unsigned long, v8::internal::AllocationSpace, v8::internal::Executability, void*, v8::internal::VirtualMemory*) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  6: 0x11359b4 v8::internal::MemoryAllocator::AllocateUninitializedChunkAt(v8::internal::BaseSpace*, unsigned long, v8::internal::Executability, unsigned long, v8::internal::PageSize) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  7: 0x11360db v8::internal::MemoryAllocator::AllocatePage(v8::internal::MemoryAllocator::AllocationMode, v8::internal::Space*, v8::internal::Executability) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  8: 0x114afac v8::internal::PagedSpaceBase::TryExpandImpl() [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]:  9: 0x114d9d4  [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 10: 0x114df82 v8::internal::PagedSpaceBase::RefillLabMain(int, v8::internal::AllocationOrigin) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 11: 0x10ba455 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 12: 0x10972b5 v8::internal::Factory::CodeBuilder::AllocateInstructionStream(bool) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 13: 0x109768a v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 14: 0xf0fc77 v8::internal::baseline::BaselineCompiler::Build(v8::internal::LocalIsolate*) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 15: 0xf1fe35 v8::internal::GenerateBaselineCode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 16: 0xf7bc2b v8::internal::Compiler::CompileSharedWithBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 17: 0xf7c17d v8::internal::Compiler::CompileBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 18: 0xf0e3e8 v8::internal::baseline::BaselineBatchCompiler::CompileBatch(v8::internal::Handle<v8::internal::JSFunction>) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 19: 0x1053c64 v8::internal::TieringManager::OnInterruptTick(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::CodeKind) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 20: 0x14f1da3  [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 21: 0x14f3594 v8::internal::Runtime_BytecodeBudgetInterruptWithStackCheck_Ignition(int, unsigned long*, v8::internal::Isolate*) [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716626]: 22: 0x192def6  [node]
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: lightningd: FATAL SIGNAL 11 (version v24.08)
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf5613a530 send_backtrace
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         common/daemon.c:33
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf5613a5b8 crashdump
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         common/daemon.c:75
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x7fdb05b7d04f ???
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ???:0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf5610bdab plugin_conn_finish
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         lightningd/plugin.c:878
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562a5d79 destroy_conn
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/io/poll.c:246
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562a5d9b destroy_conn_close_fd
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/io/poll.c:252
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562afa45 notify
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/tal/tal.c:246
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562afb1d del_tree
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/tal/tal.c:437
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562b0005 tal_free
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/tal/tal.c:532
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562a49be io_close
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/io/io.c:496
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf562a6391 io_loop
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ccan/ccan/io/poll.c:459
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf560e14e8 io_loop_with_timers
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         lightningd/io_loop_with_timers.c:22
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf5610d8bb plugins_init
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         lightningd/plugin.c:2098
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf560e668f main
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         lightningd/lightningd.c:1243
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x7fdb05b68249 ???
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ???:0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x7fdb05b68304 ???
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ???:0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0x55cf560bbf10 ???
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ???:0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]: 0xffffffffffffffff ???
Sep 14 19:47:40 raspiblitz-amd64 sh[1716596]:         ???:0
Sep 14 19:47:40 raspiblitz-amd64 sh[1716592]: Segmentation fault
Sep 14 19:47:40 raspiblitz-amd64 systemd[1]: lightningd.service: Main process exited, code=exited, status=139/n/a
Sep 14 19:47:40 raspiblitz-amd64 systemd[1]: lightningd.service: Failed with result 'exit-code'.
Sep 14 19:47:40 raspiblitz-amd64 systemd[1]: Failed to start lightningd.service - c-lightning daemon on mainnet.
joelklabo commented 1 month ago

I haven't looked at this in a while. Sorry, I'll see if I can take a look this weekend though.