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

Eduardo/renepay #12

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
baa3732
add a simple MCF to get started
Apr 14, 2023
26a5d71
allocate gossmap as children of pay
Apr 17, 2023
2212096
add comments on the idea to combine costs
Apr 17, 2023
e9b8fb0
add channel/arc linearization
Apr 18, 2023
6cd316b
renepay: use a queue to traverse the graph
Apr 18, 2023
8be7a36
renepay: implement prob. and fee cost from flow
Apr 18, 2023
ff8b4c9
renepay: split a flow into path flows
Apr 19, 2023
5c97151
renepay: use shortest augmenting path for MCF
Apr 21, 2023
cb6f459
renepay: search the optimal path with Dijkstra
Apr 24, 2023
c670d3b
renepay: infinity is INT64_MAX
Apr 24, 2023
4ca1294
renepay: remove inline specifier and ASSERT
Apr 24, 2023
2446770
renepay: use tal_arrz to initialize to zero
Apr 24, 2023
349641c
renepay: fix a couple of minor details
Apr 24, 2023
686a90c
renepay: encode arcs with bitfields
Apr 24, 2023
71b8633
renepay: fix some compiler errors
Apr 27, 2023
89099e5
renepay: add a heap without global variables
Apr 29, 2023
a9058be
renepay: use a global dijkstra heap
Apr 29, 2023
69bc4b5
reneplay: bugfix
Apr 29, 2023
328c74e
renepay: fix small details
May 4, 2023
72b0823
renepay: added conditional probability on arc
May 5, 2023
f4217bb
renepay: refactoring the code and make it compile
May 8, 2023
86aefc4
renepay: removing seg-fault bugs
May 10, 2023
a9e9830
renepay: done some unitests and bugfixes
May 11, 2023
ea93f9e
renepay: unit test and bugfix dijkstra heap
May 12, 2023
8562901
renepay: testing order of destructor calls
May 12, 2023
72702a4
renepay: unittest edge_probability
May 12, 2023
c9f8035
renepay: remove unnecessary functions
May 12, 2023
059ee9a
renepay: know min and max in halves is redundant
May 15, 2023
f557dc5
renepay: testing flow_complete function
May 15, 2023
d927193
renepay: trying to get pay work
May 17, 2023
b9b6200
renepay: use listpeerchannels instead of listpeers
May 17, 2023
8bc35d8
renepay: routehints only after maxspend is known
May 17, 2023
c475d32
renepay: remove printf loggin
May 17, 2023
e2609ba
renepay: bugfix on sendpay rpc request
May 18, 2023
27ce759
renepay: debuging utils for pay_flows
May 19, 2023
35bf034
renepay: add payment_secret to sendpay request
May 22, 2023
3347b03
renepay: fixed problem with MPP
May 24, 2023
309db4f
renepay: add knowledge update functions
May 29, 2023
5f37cad
renepay: fix seg. fault for waitsendpay_fail
May 29, 2023
cf74699
renepay: add debuging utils
May 29, 2023
1e07e7e
renepay: add destructor for payment data
May 29, 2023
a9fa2af
renepay: remove assumption of liquidity for hints
May 29, 2023
0257379
renepay: add/remove HTLC in the uncertainty net.
May 29, 2023
f400ed9
renepay: use generic debug functions
Jun 2, 2023
fb6b195
renepay: remove mock functions from tests
Jun 2, 2023
c7b8809
renepay: add a print function for chan_extra_map
Jun 2, 2023
09e1634
renepay: improve flow select in MCF
Jun 2, 2023
b92a220
renepay: refactoring the payment mechanics
Jun 9, 2023
8bd3d3e
renepay: update channel gossip from onion error
Jun 9, 2023
a1a88ee
renepay: remove bug that crashed pay after success
Jun 13, 2023
8498ccd
renepay: debug message are sent to the log file
Jun 15, 2023
66e71ac
renepay: add renepay to default plugins
Jun 20, 2023
b94ebe0
renepay: add pyln-testing
Jun 20, 2023
c77e743
renepay: testing different ways to cleanup at shutdown
Jun 21, 2023
fbca98c
renepay: on critical error log messages
Jun 22, 2023
2ed8fc8
renepay: call listsendpay before payment
Jun 22, 2023
0067712
renepay: don't record twice for the same payment
Jun 22, 2023
55e8dab
renepay: code review, remove old comments
Jun 23, 2023
ddaf64f
renepay: add msat precision payments
Jun 25, 2023
0e6e5d6
renepay: add error messages from pay_flow
Jun 25, 2023
0926bf0
renepay: can complete pending MPP
Jun 26, 2023
3125d26
renepay: bugfix
Jun 27, 2023
a05f504
renepay: restructure the code (read below)
Jun 30, 2023
00c2035
renepay: use sendpay notifications
Jul 3, 2023
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ CCAN_HEADERS := \
$(CCANDIR)/ccan/json_out/json_out.h \
$(CCANDIR)/ccan/likely/likely.h \
$(CCANDIR)/ccan/list/list.h \
$(CCANDIR)/ccan/lqueue/lqueue.h \
$(CCANDIR)/ccan/mem/mem.h \
$(CCANDIR)/ccan/membuf/membuf.h \
$(CCANDIR)/ccan/noerr/noerr.h \
Expand Down Expand Up @@ -448,7 +449,9 @@ else
PYTEST_OPTS += -x
endif

check-units:
check-units: check-renepay

check-renepay:

check: check-units installcheck check-protos pytest

Expand Down
1 change: 1 addition & 0 deletions ccan/ccan/lqueue/LICENSE
57 changes: 57 additions & 0 deletions ccan/ccan/lqueue/_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "config.h"
#include <stdio.h>
#include <string.h>

/**
* lqueue - Simple, singly-linked-list queue implementation
*
* This code provides a simple implementation of the Queue abstract
* data type in terms of a singly linked (circular) list.
*
* License: BSD-MIT
* Author: David Gibson <david@gibson.dropbear.id.au>
*
* Example:
* #include <ccan/lqueue/lqueue.h>
*
* struct arg {
* const char *arg;
* struct lqueue_link ql;
* };
*
* int main(int argc, char *argv[])
* {
* int i;
* struct arg *a;
* LQUEUE(struct arg, ql) argq = LQUEUE_INIT;
*
* for (i = 0; i < argc; i++) {
* a = malloc(sizeof(*a));
* a->arg = argv[i];
* lqueue_enqueue(&argq, a);
* }
*
* printf("Command line arguments in order:\n");
*
* while (!lqueue_empty(&argq)) {
* a = lqueue_dequeue(&argq);
* printf("Argument: %s\n", a->arg);
* free(a);
* }
*
* return 0;
* }
*/
int main(int argc, char *argv[])
{
/* Expect exactly one argument */
if (argc != 2)
return 1;

if (strcmp(argv[1], "depends") == 0) {
printf("ccan/tcon\n");
return 0;
}

return 1;
}
238 changes: 238 additions & 0 deletions ccan/ccan/lqueue/lqueue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
/* Licensed under BSD-MIT - see LICENSE file for details */
#ifndef CCAN_LQUEUE_H
#define CCAN_LQUEUE_H

#include <stdbool.h>
#include <stdio.h>
#include <assert.h>

#include <ccan/tcon/tcon.h>

/**
* struct lqueue_link - a queue link
* @next: next entry, or front of queue, if this is the back
*
* This is used as a link within a queue entry.
*
* Example:
* struct waiter {
* char *name;
* struct lqueue_link ql;
* };
*/
struct lqueue_link {
struct lqueue_link *next;
};

/**
* struct lqueue_ - a queue (internal type)
* @b: the back of the queue (NULL if empty)
*/
struct lqueue_ {
struct lqueue_link *back;
};

/**
* LQUEUE - declare a queue
* @type: the type of elements in the queue
* @link: the field containing the lqueue_link in @type
*
* The LQUEUE macro declares an lqueue. It can be prepended by
* "static" to define a static lqueue. The queue begins in undefined
* state, you must either initialize with LQUEUE_INIT, or call
* lqueue_init() before using it.
*
* See also:
* lqueue_init()
*
* Example:
* struct element {
* int value;
* struct lqueue_link link;
* };
* LQUEUE(struct element, link) my_queue;
*/
#define LQUEUE(etype, link) \
TCON_WRAP(struct lqueue_, \
TCON_CONTAINER(canary, etype, link))

/**
* LQUEUE_INIT - initializer for an empty queue
*
* The LQUEUE_INIT macro returns a suitable initializer for a queue
* defined with LQUEUE.
*
* Example:
* struct element {
* int value;
* struct lqueue_link link;
* };
* LQUEUE(struct element, link) my_queue = LQUEUE_INIT;
*
* assert(lqueue_empty(&my_queue));
*/
#define LQUEUE_INIT \
TCON_WRAP_INIT({ NULL, })

/**
* lqueue_entry - convert an lqueue_link back into the structure containing it.
* @q: the queue
* @l: the lqueue_link
*
* Example:
* struct waiter {
* char *name;
* struct lqueue_link ql;
* } w;
* LQUEUE(struct waiter, ql) my_queue;
* assert(lqueue_entry(&my_queue, &w.ql) == &w);
*/
#define lqueue_entry(q_, l_) tcon_container_of((q_), canary, (l_))

/**
* lqueue_init_from_back - initialize a queue with a specific back element
* @s: the lqueue to initialize
* @e: pointer to the back element of the new queue
*
* USE WITH CAUTION: This is for handling unusual cases where you have
* a pointer to an element in a previously constructed queue but can't
* conveniently pass around a normal struct lqueue. Usually you
* should use lqueue_init().
*
* Example:
* struct element {
* int value;
* struct lqueue_link link;
* } el;
* LQUEUE(struct element, link) queue1;
* LQUEUE(struct element, link) queue2;
*
* lqueue_enqueue(&queue1, &el);
*
* lqueue_init_from_back(&queue2, lqueue_back(&queue1));
*/
#define lqueue_init_from_back(q_, e_) \
(lqueue_init_(tcon_unwrap(q_), tcon_member_of((q_), canary, (e_))))

/**
* lqueue_init - initialize a queue
* @h: the lqueue to set to an empty queue
*
* Example:
* struct element {
* int value;
* struct lqueue_link link;
* };
* LQUEUE(struct element, link) *qp = malloc(sizeof(*qp));
* lqueue_init(qp);
*/
#define lqueue_init(q_) \
(lqueue_init_(tcon_unwrap(q_), NULL))
static inline void lqueue_init_(struct lqueue_ *q, struct lqueue_link *back)
{
q->back = back;
}

/**
* lqueue_empty - is a queue empty?
* @q: the queue
*
* If the queue is empty, returns true.
*/
#define lqueue_empty(q_) \
lqueue_empty_(tcon_unwrap(q_))
static inline bool lqueue_empty_(const struct lqueue_ *q)
{
return (q->back == NULL);
}

/**
* lqueue_front - get front entry in a queue
* @q: the queue
*
* If the queue is empty, returns NULL.
*
* Example:
* struct element *f;
*
* f = lqueue_front(qp);
* assert(lqueue_dequeue(qp) == f);
*/
#define lqueue_front(q_) \
lqueue_entry((q_), lqueue_front_(tcon_unwrap(q_)))
static inline struct lqueue_link *lqueue_front_(const struct lqueue_ *q)
{
if (!q->back)
return NULL;
else
return q->back->next;
}

/**
* lqueue_back - get back entry in a queue
* @q: the queue
*
* If the queue is empty, returns NULL.
*
* Example:
* struct element b;
*
* lqueue_enqueue(qp, &b);
* assert(lqueue_back(qp) == &b);
*/
#define lqueue_back(q_) \
lqueue_entry((q_), lqueue_back_(tcon_unwrap(q_)))
static inline struct lqueue_link *lqueue_back_(const struct lqueue_ *q)
{
return q->back;
}

/**
* lqueue_enqueue - add an entry to the back of a queue
* @q: the queue to add the node to
* @e: the item to enqueue
*
* The lqueue_link does not need to be initialized; it will be overwritten.
*/
#define lqueue_enqueue(q_, e_) \
lqueue_enqueue_(tcon_unwrap(q_), tcon_member_of((q_), canary, (e_)))
static inline void lqueue_enqueue_(struct lqueue_ *q, struct lqueue_link *e)
{
if (lqueue_empty_(q)) {
/* New entry will be both front and back of queue */
e->next = e;
q->back = e;
} else {
e->next = lqueue_front_(q);
q->back->next = e;
q->back = e;
}
}

/**
* lqueue_dequeue - remove and return the entry from the front of the queue
* @q: the queue
*
* Note that this leaves the returned entry's link in an undefined
* state; it can be added to another queue, but not deleted again.
*/
#define lqueue_dequeue(q_) \
lqueue_entry((q_), lqueue_dequeue_(tcon_unwrap(q_)))
static inline struct lqueue_link *lqueue_dequeue_(struct lqueue_ *q)
{
struct lqueue_link *front;

if (lqueue_empty_(q))
return NULL;

front = lqueue_front_(q);
if (front == lqueue_back_(q)) {
assert(front->next == front);
q->back = NULL;
} else {
q->back->next = front->next;
}
return front;
}

#endif /* CCAN_LQUEUE_H */
69 changes: 69 additions & 0 deletions ccan/ccan/lqueue/test/run.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "config.h"

#include <ccan/lqueue/lqueue.h>
#include <ccan/tap/tap.h>

struct waiter {
const char *name;
struct lqueue_link ql;
};

int main(void)
{
LQUEUE(struct waiter, ql) q = LQUEUE_INIT;
struct waiter a = { "Alice" };
struct waiter b = { "Bob" };
struct waiter c = { "Carol" };
struct waiter *waiter;

/* This is how many tests you plan to run */
plan_tests(25);

ok1(lqueue_empty(&q));
ok1(lqueue_front(&q) == NULL);
ok1(lqueue_back(&q) == NULL);

lqueue_enqueue(&q, &a);

ok1(!lqueue_empty(&q));
ok1(lqueue_front(&q) == &a);
ok1(lqueue_back(&q) == &a);

lqueue_enqueue(&q, &b);

ok1(!lqueue_empty(&q));
ok1(lqueue_front(&q) == &a);
ok1(lqueue_back(&q) == &b);

lqueue_enqueue(&q, &c);

ok1(!lqueue_empty(&q));
ok1(lqueue_front(&q) == &a);
ok1(lqueue_back(&q) == &c);

waiter = lqueue_dequeue(&q);
ok1(waiter == &a);

ok1(!lqueue_empty(&q));
ok1(lqueue_front(&q) == &b);
ok1(lqueue_back(&q) == &c);

waiter = lqueue_dequeue(&q);
ok1(waiter == &b);

ok1(!lqueue_empty(&q));
ok1(lqueue_front(&q) == &c);
ok1(lqueue_back(&q) == &c);

waiter = lqueue_dequeue(&q);
ok1(waiter == &c);

ok1(lqueue_empty(&q));
ok1(lqueue_front(&q) == NULL);
ok1(lqueue_back(&q) == NULL);

ok1(lqueue_dequeue(&q) == NULL);

/* This exits depending on whether all tests passed */
return exit_status();
}
3 changes: 2 additions & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ C_PLUGINS := \
plugins/offers \
plugins/pay \
plugins/txprepare \
plugins/spenderp
plugins/spenderp \
plugins/cln-renepay

ifeq ($(HAVE_SQLITE3),1)
C_PLUGINS += plugins/sql
Expand Down
Loading