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

Remote Signer Proxy #6

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open

Remote Signer Proxy #6

wants to merge 54 commits into from

Conversation

ksedgwic
Copy link
Collaborator

This PR adds an alternate implementation of c-lightning's hsmd daemon. The private keys and secrets are sequestered in an external program, the Remote Lightning Signer. This remote-hsmd daemon proxies all signing requests to the remote daemon.

Please see the Lightning Signer Overview for more information.

@ulrichard
Copy link

Please add libgrpc-dev and libgrpc++-dev to the dependencies section in doc/INSTALL.md

But still with this installed, I get a compilation error:
contrib/remote_hsmd/proxy.cc:6:10: fatal error: contrib/remote_hsmd/remotesigner.grpc.pb.h: File or directory not found
| #include "contrib/remote_hsmd/remotesigner.grpc.pb.h"

@ksedgwic
Copy link
Collaborator Author

ksedgwic commented Apr 23, 2021

Will fix, thanks!

More detailed notes for our proxy can be found in contrib/remote_hsmd/NOTES.md.

The error you are seeing suggests that the protobuf compiler is not being run to generate the .pb.c and .pb.h files.

Do you have the following symbolic link to a sibling rust-lightning-signer checkout?

$ ls -l contrib/remote_hsmd/remotesigner.proto
lrwxrwxrwx 1 user user 60 Oct 16  2020 contrib/remote_hsmd/remotesigner.proto -> ../../../rust-lightning-signer/src/server/remotesigner.proto

Also, a rebase of the proxy onto the current c-lightning master branch is in the works, please let me know if that would be useful to you.

@ulrichard
Copy link

Thanks for the hints.
Yes, I didn't have the symbolic link in place.
And I also had to install protobuf-compiler-grpc
With those two changes, it compiles successfully.

@ksedgwic
Copy link
Collaborator Author

ksedgwic commented May 2, 2021

Thanks for the hints.
Yes, I didn't have the symbolic link in place.
And I also had to install protobuf-compiler-grpc
With those two changes, it compiles successfully.

@ulrichard I've (force) pushed a new version of this branch which is based on a much newer c-lightning version.

@ksedgwic ksedgwic force-pushed the remote-hsmd branch 4 times, most recently from 2bdab31 to 04ce198 Compare August 31, 2021 16:39
ksedgwic pushed a commit that referenced this pull request Sep 8, 2021
The variable `block` (instace of `struct block`) is
allocated on the stack without being initialized, i.e. its
member `prev` points to nowhere. This causes a segmentation
fault on my machine on the binding of "prev_hash" on running
`wallet_block_add`, as the following core-dump analysis
shows:

    $ egdb ./wallet/test/run-wallet ./run-wallet.core
    [...]
    Core was generated by `run-wallet'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    ---Type <return> to continue, or q <return> to quit---
    #0  0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
    97                      TLOOP1(*dst++ = *src++);
    (gdb) bt
    #0  0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
    #1  0x000008f73e838f60 in sqlite3VdbeMemSetStr () from /usr/local/lib/libsqlite3.so.37.12
    #2  0x000008f73e83cb11 in bindText () from /usr/local/lib/libsqlite3.so.37.12
    #3  0x000008f44bc91345 in db_sqlite3_query (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:77
    #4  0x000008f44bc91122 in db_sqlite3_exec (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:110
    #5  0x000008f44bcbb3b2 in db_exec_prepared_v2 (stmt=0x8f6845bf028) at ./wallet/db.c:2055
    #6  0x000008f44bcc6890 in wallet_block_add (w=0x8f688b5bba8, b=0x7f7ffffca788) at ./wallet/wallet.c:3556
    #7  0x000008f44bce2607 in test_wallet_outputs (ld=0x8f6a35a7828, ctx=0x8f6a35c0268) at wallet/test/run-wallet.c:1104
    #8  0x000008f44bcddec0 in main (argc=1, argv=0x7f7ffffcaaf8) at wallet/test/run-wallet.c:1930

Fix by explicitely setting the whole structure to zero.

[ Rebuilt generated files, too --RR ]
@ksedgwic ksedgwic changed the base branch from master to remote-hsmd-base October 26, 2021 20:33
@ksedgwic ksedgwic changed the base branch from remote-hsmd-base to master March 16, 2022 17:19
@ksedgwic ksedgwic force-pushed the remote-hsmd branch 2 times, most recently from d4586fb to 997e006 Compare March 21, 2022 17:40
@devrandom devrandom force-pushed the remote-hsmd branch 2 times, most recently from 321ef87 to 73d40f4 Compare March 29, 2022 15:59
ksedgwic pushed a commit that referenced this pull request Aug 3, 2023
It is possible for db_column_bytes() to return 0 and for
db_column_blob() to return NULL even when db_column_is_null() returns
false. We need to short circuit in this case.

Detected by UBSan:

  db/bindings.c:479:12: runtime error: null pointer passed as argument 2, which is declared to never be null
  /usr/include/string.h:44:28: note: nonnull attribute specified here

  #0 0x95f117 in db_col_arr_ db/bindings.c:479:2
  #1 0x95ef85 in db_col_channel_type db/bindings.c:459:32
  #2 0x852c03 in wallet_stmt2channel wallet/wallet.c:1483:9
  #3 0x81f396 in wallet_channels_load_active wallet/wallet.c:1749:23
  #4 0x81f03d in wallet_init_channels wallet/wallet.c:1765:9
  #5 0x72f1f9 in load_channels_from_wallet lightningd/peer_control.c:2257:7
  #6 0x672856 in main lightningd/lightningd.c:1121:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants