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

Add esplora plugin from lvaccaro #1

Closed
wants to merge 1 commit into from
Closed

Add esplora plugin from lvaccaro #1

wants to merge 1 commit into from

Conversation

jsarenik
Copy link
Owner

@jsarenik jsarenik commented Nov 26, 2020

@jsarenik
Copy link
Owner Author

The force-push history will be tracked in this fake PR. So far my local reflog says this:

$ git reflog | grep esplora
70977a4fb HEAD@{0}: checkout: moving from jsn/esplora to master
33f2863b8 HEAD@{1}: commit (amend): Add esplora plugin from lvaccaro
5312d5ff7 HEAD@{2}: rebase finished: returning to refs/heads/jsn/esplora
5312d5ff7 HEAD@{3}: rebase: Add esplora plugin from lvaccaro
c5a8d615d HEAD@{5}: checkout: moving from master to jsn/esplora
ff090ecfe HEAD@{7}: checkout: moving from jsn/esplora to master
c5a8d615d HEAD@{8}: rebase finished: returning to refs/heads/jsn/esplora
c5a8d615d HEAD@{9}: rebase: Add esplora plugin from lvaccaro
5398d2ded HEAD@{11}: checkout: moving from master to jsn/esplora
66b2bb9a9 HEAD@{13}: checkout: moving from jsn/esplora to master
5398d2ded HEAD@{14}: commit: Add esplora plugin from lvaccaro
66b2bb9a9 HEAD@{15}: checkout: moving from master to jsn/esplora

@jsarenik
Copy link
Owner Author

The steps I use to update this branch are:

cd ~/src/lightning
git checkout master
git pull
git push jsn
git checkout jsn/esplora
git rebase master
git push --force jsn

@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from b95e4b7 to d293e6e Compare December 6, 2020 19:45
@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from 8b137a1 to 1938c01 Compare December 13, 2020 16:35
@jsarenik
Copy link
Owner Author

The tests are currently broken by this:

lightningd-1: 2020-12-13T16:57:49.946Z **BROKEN** plugin-esplora: Plugin marked as important, shutting down lightningd!

@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from 477616d to 773f013 Compare December 18, 2020 09:26
@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from 6e194b8 to 793331d Compare January 28, 2021 08:17
@jsarenik
Copy link
Owner Author

jsarenik commented Feb 2, 2021

It corrently throws a compilation error:

plugins/esplora.c: In function ‘main’:
plugins/esplora.c:776:12: error: passing argument 2 of ‘plugin_main’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  776 |      argv, init, PLUGIN_STATIC, false, NULL, commands,
      |            ^~~~
      |            |
      |            void (*)(struct plugin *, const char *, const jsmntok_t *) {aka void (*)(struct plugin *, const char *, const struct <anonymous> *)}
In file included from plugins/esplora.c:22:
./plugins/libplugin.h:280:20: note: expected ‘const char * (*)(struct plugin *, const char *, const jsmntok_t *)’ {aka ‘const char * (*)(struct plugin *, const char *, const struct <anonymous> *)’} but argument is of type ‘void (*)(struct plugin *, const char *, const jsmntok_t *)’ {aka ‘void (*)(struct plugin *, const char *, const struct <anonymous> *)’}
  280 |      const char *(*init)(struct plugin *p,
      |      ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
  281 |            const char *buf,
      |            ~~~~~~~~~~~~~~~~
  282 |            const jsmntok_t *),
      |            ~~~~~~~~~~~~~~~~~~

@jsarenik
Copy link
Owner Author

jsarenik commented Feb 2, 2021

Compilation error fixed:

diff --git a/plugins/esplora.c b/plugins/esplora.c
index 2657c345e..6ab1fb27b 100644
--- a/plugins/esplora.c
+++ b/plugins/esplora.c
@@ -671,7 +671,7 @@ static bool configure_esplora_with_network(const char *network,
 	return false;
 }
 
-static void init(struct plugin *p, const char *buffer, const jsmntok_t *config)
+static const char *init(struct plugin *p, const char *buffer, const jsmntok_t *config)
 {
 	const jsmntok_t *proxy_tok = json_get_member(buffer, config, "proxy");
 	if (proxy_tok) {
@@ -719,6 +719,7 @@ static void init(struct plugin *p, const char *buffer, const jsmntok_t *config)
 	if (proxy_conf->proxy_enabled && !esplora->proxy_disabled)
 		plugin_log(p, LOG_INFORM, "proxy configuration %s:%d",
 			   proxy_conf->address, proxy_conf->port);
+	return NULL;
 }
 
 static struct esplora *new_esplora(const tal_t *ctx)

@jsarenik
Copy link
Owner Author

jsarenik commented Feb 2, 2021

@vincenzopalazzo FYI ^^ (see above)

@vincenzopalazzo
Copy link
Collaborator

vincenzopalazzo commented Feb 2, 2021

@jsarenik hello, I will take a look to compile it in my dev environment and I will return back here when I have some feedback at the moment it looks good. What do you think @lvaccaro?

Update: I missed this update inside the lightning ElementsProject@27c006f.

ack 157b4c4

@jsarenik jsarenik force-pushed the jsn/esplora branch 7 times, most recently from c78b105 to 5b2e972 Compare February 11, 2021 15:36
@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from e57c371 to 6dd484b Compare April 13, 2021 08:16
@jsarenik
Copy link
Owner Author

Now that I finally have a simple script I am thinking about discontinuing this branch. What do you think @lvaccaro and @vincenzopalazzo? Thank you!

@vincenzopalazzo
Copy link
Collaborator

@jsarenik concept ack for the script. It looks good to me, and I will test it on my local machine soon.

I am thinking about discontinuing this branch

This is up to you :)

@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from bb47a09 to ecaa108 Compare April 25, 2021 18:03
@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from e7f817c to 102dd18 Compare May 4, 2021 08:42
@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from 425f0ea to 31cc0d0 Compare May 12, 2021 15:36
@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from 7c51902 to f01dfd4 Compare May 18, 2021 14:50
@jsarenik jsarenik force-pushed the jsn/esplora branch 3 times, most recently from 216f0a7 to 928dd2c Compare May 24, 2021 16:06
@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from d530449 to 514bc64 Compare June 28, 2021 20:40
jsarenik pushed a commit that referenced this pull request Sep 12, 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
    ElementsProject#2  0x000008f73e83cb11 in bindText () from /usr/local/lib/libsqlite3.so.37.12
    ElementsProject#3  0x000008f44bc91345 in db_sqlite3_query (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:77
    ElementsProject#4  0x000008f44bc91122 in db_sqlite3_exec (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:110
    ElementsProject#5  0x000008f44bcbb3b2 in db_exec_prepared_v2 (stmt=0x8f6845bf028) at ./wallet/db.c:2055
    ElementsProject#6  0x000008f44bcc6890 in wallet_block_add (w=0x8f688b5bba8, b=0x7f7ffffca788) at ./wallet/wallet.c:3556
    ElementsProject#7  0x000008f44bce2607 in test_wallet_outputs (ld=0x8f6a35a7828, ctx=0x8f6a35c0268) at wallet/test/run-wallet.c:1104
    ElementsProject#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 ]
@jsarenik jsarenik force-pushed the jsn/esplora branch 2 times, most recently from 921315d to bb55275 Compare September 23, 2021 10:18
@jsarenik jsarenik closed this Apr 22, 2022
@jsarenik jsarenik deleted the jsn/esplora branch April 22, 2022 05:20
jsarenik pushed a commit that referenced this pull request Mar 5, 2023
This will fix a crash that I caused on armv7
and by looking inside the coredump with gdb
(by adding an assert on n that must be
different from null) I get the following stacktrace

```
(gdb) bt
\#0  0x00000000 in ?? ()
\#1  0x0043a038 in send_backtrace (why=0xbe9e3600 "FATAL SIGNAL 11") at common/daemon.c:36
\ElementsProject#2  0x0043a0ec in crashdump (sig=11) at common/daemon.c:46
\ElementsProject#3  <signal handler called>
\ElementsProject#4  0x00406d04 in node_announcement (map=0x938ecc, nann_off=495146) at common/gossmap.c:586
\ElementsProject#5  0x00406fec in map_catchup (map=0x938ecc, num_rejected=0xbe9e3a40) at common/gossmap.c:643
\ElementsProject#6  0x004073a4 in load_gossip_store (map=0x938ecc, num_rejected=0xbe9e3a40) at common/gossmap.c:697
\ElementsProject#7  0x00408244 in gossmap_load (ctx=0x0, filename=0x4e16b8 "gossip_store", num_channel_updates_rejected=0xbe9e3a40) at common/gossmap.c:976
\ElementsProject#8  0x0041a548 in init (p=0x93831c, buf=0x9399d4 "\n\n{\"jsonrpc\":\"2.0\",\"id\":\"cln:init#25\",\"method\":\"init\",\"params\":{\"options\":{},\"configuration\":{\"lightning-dir\":\"/home/vincent/.lightning/testnet\",\"rpc-file\":\"lightning-rpc\",\"startup\":true,\"network\":\"te"..., config=0x939cdc) at plugins/topology.c:622
\ElementsProject#9  0x0041e5d0 in handle_init (cmd=0x938934, buf=0x9399d4 "\n\n{\"jsonrpc\":\"2.0\",\"id\":\"cln:init#25\",\"method\":\"init\",\"params\":{\"options\":{},\"configuration\":{\"lightning-dir\":\"/home/vincent/.lightning/testnet\",\"rpc-file\":\"lightning-rpc\",\"startup\":true,\"network\":\"te"..., params=0x939c8c)
    at plugins/libplugin.c:1208
\ElementsProject#10 0x0041fc04 in ld_command_handle (plugin=0x93831c, toks=0x939bec) at plugins/libplugin.c:1572
\ElementsProject#11 0x00420050 in ld_read_json_one (plugin=0x93831c) at plugins/libplugin.c:1667
\ElementsProject#12 0x004201bc in ld_read_json (conn=0x9391c4, plugin=0x93831c) at plugins/libplugin.c:1687
\ElementsProject#13 0x004cb82c in next_plan (conn=0x9391c4, plan=0x9391d8) at ccan/ccan/io/io.c:59
\ElementsProject#14 0x004cc67c in do_plan (conn=0x9391c4, plan=0x9391d8, idle_on_epipe=false) at ccan/ccan/io/io.c:407
\ElementsProject#15 0x004cc6dc in io_ready (conn=0x9391c4, pollflags=1) at ccan/ccan/io/io.c:417
\ElementsProject#16 0x004cf8cc in io_loop (timers=0x9383c4, expired=0xbe9e3ce4) at ccan/ccan/io/poll.c:453
\ElementsProject#17 0x00420af4 in plugin_main (argv=0xbe9e3eb4, init=0x41a46c <init>, restartability=PLUGIN_STATIC, init_rpc=true, features=0x0, commands=0x6167e8 <commands>, num_commands=4, notif_subs=0x0, num_notif_subs=0, hook_subs=0x0, num_hook_subs=0, notif_topics=0x0, num_notif_topics=0) at plugins/libplugin.c:1891
\ElementsProject#18 0x0041a6f8 in main (argc=1, argv=0xbe9e3eb4) at plugins/topology.c:679
```

I do not know if this is a solution because I do not know
when I can parse a node announcement for a node that
it is not longer in the gossip map.

So, I hope this is just usefult for @rustyrussell

Changelog-Fixed: fixes `FATAL SIGNAL 11` on gossmap node announcement parsing.

Signed-off-by: Vincenzo Palazzo <[email protected]>
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.

3 participants